Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a new variable, and prompt the user to input a letter grade (for example,

ID: 3573288 • Letter: C

Question

Create a new variable, and prompt the user to input a letter grade (for example, “A” or “a”) to populate this new variable. Use If-Then-Else or Switch to evaluate the user input and print the results to Standard Output as follows: Print out “Pass” if the user input is A, B, or C (including low cases). Print out “Fail” if the user input is D or F (including low cases). Print out “Grade is not recognized” for any other inputs. Use While loop or For loop to print out 5 integer numbers (1 – 5) in backorder, one per line, to Standard Output.

Explanation / Answer


import java.util.*;
public class grade {
   public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       System.out.println("enter Grade:");
       char grade=sc.next().charAt(0);
       if(grade=='A'||grade=='a'||grade=='B'||grade=='b'||grade=='C'||grade=='c')
           System.out.println("Pass");
       else if(grade=='D'||grade=='d'||grade=='f'||grade=='F')
       System.out.println("Fail");
       else
           System.out.println("not recognized");
       for(int i=5;i>0;i--)
           System.out.println(i);
   }
}
output:
if grade a,b,c,A,B,C are given as input:
enter Grade:
c
Pass
5
4
3
2
1
output:if d ,f,F,D are given as input:
enter Grade:
d
Fail
5
4
3
2
1
output if other inputs are given:
enter Grade:
s
not recognized
5
4
3
2
1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote