Answer:
import java.util.Scanner;
public class num7 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the grade 60-100");
double grade = in.nextDouble();
while(grade<60 ||grade>100){
System.out.println("Enter a valid grade 60-100");
grade= in.nextDouble();
}
double outVal;
if(grade>=60 && grade<70){
outVal = 0.0;
}
else if(grade>=70 && grade<80){
outVal = 1.0;
}
else if(grade>=80 && grade<90){
outVal = 2.0;
}
else if(grade>=90 && grade<100){
outVal = 3.0;
}
else{
outVal = 4.0;
}
System.out.println("The converted grade is: "+outVal);
}
}
Step-by-step explanation:
- The program is written in Java
- User is prompted to enter a grade between 60-100
- A while loop is used to validate user input
- If/else if/else statements are used to convert the values as required
- the output value is stored as a double