Create an Java Project and Java Class named Honorsjava to pe
Solution
The way to create a project in Eclipse IDE would be to Go to New Project -> Java Project and giving it an appropriate name, say, Honors.java and pressing FInish. What this would do is it will create the neccessary file for you. The Honors class would be already present and have some skeletal code along with the main method already present.
//neccesary imports so that the Scanners and print statements can be used
import java.util.*;
import java.lang.*
//now creating the class Honors
public class Honors {
float gpa; //dcalration of the float variable which would hold the user input
Scanner scanny = new Scanner(System.in); //defining the Scanner object which takes in user input
//function to accept user input and accordingly print the outputs based on if - else comparison
public void getgpa(){
System.out,println(\"Enter your gps please.\");
gpa = scanny.nextFloat(); //here the scanner object takes in the next user input as a float variable.
if(gpa == 4.0)
System.out.println(\"President\'s List\");
else if (gpa < 4.0 && gpa >=3.5)
System.out.println(\"Dean\'s List\");
else if (gpa <3.5)
System.out.println(\"Did not earn honors for the quarter\");
}
//calling the main method which would be used to instantiate the class and call its method.
public static void Main (String args[]){
Honors newhonors; //a new instance of class Honors is created
newhonors.getgpa(); //the method getgpa is called here
}
}
