Programming Examples

Write a program to accept a mark obtained by a student in computer science and print the grades accordingly:


Write a program to accept a mark obtained by a student in computer science and print the grades accordingly:

Marks Grade
Above 90 A
70 to 89 B
50 to 69 C
below 50 D

Solution

import java.util.*;
class Marks
{
    public static void main(String arr[])
    {
        int m;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the marks:");
        m=sc.nextInt();
        if (m>=90)
        System.out.println("Grade=A");
        else if (m>=70)
        System.out.println("Grade=B");
        else if (m>=50)
        System.out.println("Grade=C");
        else
        System.out.println("Grade=D");
    }
}
Output


Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad