Write a program that converts an input grade from 60 to 100 and outputs a converted grade from 0.0 to 4.0. a. Minimum input value is 60, maximum is 100. b. All whole numbers must display as decimals. (0 displays as 0.0 and 3 as 3.0) The solution requires that you create a simple mathematical expression that converts the input value into the output value

Respuesta :

ijeggs

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);

   }

}

Explanation:

  1. The program is written in Java
  2. User is prompted to enter a grade between 60-100
  3. A while loop is used to validate user input
  4. If/else if/else statements are used to convert the values as required
  5. the output value is stored as a double

Otras preguntas