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


CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials 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 Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz