Computer Science, asked by alwinrocks4336, 4 months ago

2. Write a program to compute grade of students using if else adder. The grades are assignedas followed:a. Marks Gradeb. marks<50 Fc. 50<marks< 60 Cd. 60<marks<70 Be. 70<marks<80 B+f. 80<marks<90 Ag. 90<mars< 100 A+3. Write a program to check whether a date is valid or not.​

Answers

Answered by deepakkumar9254
1

Question :-

2. Write a program to compute grade of students using if else ladder. The grades are assigned as followed:

a. Marks Grade

b. marks<50 F

c. 50<marks< 60 C

d. 60<marks<70 B

e. 70<marks<80 B+

f. 80<marks<90 A

g. 90<marks< 100 A+

3. Write a program to check whether a date is valid or not.​

Answer :-

i.) Program -

import java.util.Scanner;  \\importing package

class ad  \\class declaration

{

   public static void main(String args[])  \\main()method declaration

   {

       System.out.println("Enter the marks");

       int n;  \\input object declaration

       Scanner sc=new Scanner(System.in);  \\input object creation

       n = sc.nextInt();

       if(n<50)

       {

          System.out.println("F");

       }

       else if(n>50 && n<60)

       {

          System.out.println("C");

       }

       else if(n>60 && n<70)

       {

          System.out.println("B");

       }

       else if(n>70 && n<80)

       {

          System.out.println("B+");

       }  

       else if(n>80 && n<90)

       {

          System.out.println("A");

       }  

       else if(n>90 && n<100)

       {

          System.out.println("A+");

       }  

   }

}  

Output :- in the attachment

Glossary :-

\begin{array}{| c | c | c |}\cline{1-3} \bf Variable &amp; \bf Type &amp; \bf Description \\ \cline{1-3}n &amp;\sf int &amp; to\:\:store\:\:number \\ \cline{1-3}\end{array}

ii.) Program -

import java.util.Scanner;  \\importing package

class da  \\class declaration

{

   public static void main(String args[])  \\main()method declaration

   {

       System.out.println("Enter the marks");

       int n;  \\input object declaration

       Scanner sc=new Scanner(System.in);  \\input object creation

       n = sc.nextInt();

       if(n>=1 && n<=31)

       {

           System.out.println("It is a valid date number");

       }

   }

}

Output :- in the attachment  

Glossary :-

\begin{array}{| c | c | c |}\cline{1-3} \bf Variable &amp; \bf Type &amp; \bf Description \\ \cline{1-3}n &amp;\sf int &amp; to\:\:store\:\:number \\ \cline{1-3}\end{array}

Attachments:
Similar questions