Click here to Skip to main content
15,501,036 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The division is determined as follows: Rate from 0 to less than 2:"Fail" Rate from 2 to less than 3:"Third" Rate from 3 to less than 4:"Second" Rate from 4 to 5:"First"

What I have tried:

Java
package test3;
import java.util.*;

public class Test3 {

   
    public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
           System.out.print("Enter the grade : ");

             double n = input.nextDouble();
      
      if(n>=0&&n<2)System.out.println("Fail");
      else if(n>=2&&n<3)System.out.println("Third");
       else if(n>=3&&n<4)System.out.println("Second");
       else if(n>=4&&n<5)System.out.println("First");
    }
    
}
Posted
Updated 24-Sep-22 19:02pm
v2
Comments
Patrice T 24-Sep-22 17:24pm    
And you have a question or a problem ?
Member 15766438 24-Sep-22 17:55pm    
Yes, is the attempt correct for what is stated in the question?
Member 15766438 24-Sep-22 17:55pm    
Yes, is the attempt correct for what is stated in the question?
Dave Kreskowiak 24-Sep-22 18:28pm     CRLF
That' not even a correct question. It doesn't specify what the expected input is, so how are you going to write code to process the unknown?
Member 15766438 24-Sep-22 19:07pm     CRLF
Oh my God I don't know. What is the appropriate solution to the question? Concept The question for me asks for the certificate to be divided so that the average(GPA) ranges from 0 to 5 (University GPA)

1 solution

The best way to find out if your program does what it's supposed to do is to run it and see what it does. Does it yield the correct results in all cases?

Run it with 0,1,2,3,4 and 5.
Try some intermediate values - 1.9, 3.4, etc.
Make sure you try the edge cases - the one you test for in your if statements.
You have the user input the grade. What happens if they enter -3.7 or 7.5?

When any of these tests fail use the debugger to determine where your logic went wrong. When you change code to fix an error you'll need to rerun all your tests again to make sure you didn't break something somewhere else.

Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900