Create an Java Project and Java Class named Honorsjava to pe

Create an Java Project and Java Class named \"Honors.java\" to perform the following tasks: Write a program that prompts the user for the grade point average (GPA) earned by a student for a quarter, If the GPA is equal to 4.0, output \"President\'s List\" If the GPA is less than 4.0 and greater than or equal to 3.5, output \"Dean\'s List\" If the GPA is less than 3.5, output \"Did not earn honors for the quarter\"

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

}

}

 Create an Java Project and Java Class named \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site