Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having great difficulty with my Java Gradebook Application. I cannot figure

ID: 3648282 • Letter: I

Question

I am having great difficulty with my Java Gradebook Application. I cannot figure out what do next to accomplish this task.

The constraints:


OBJECTIVES:
Through this lab, students will review:
-How to create and compile a Java project on eclipse editor or other editor
-What is the structure of a controlling class
-What is the structure of a class
-How to declare an object of a class
-How to access members of class
-How to write and access the method toString
-Apply the Selection and Repetition structure to the program

PART1:
REQUIREMENT
Write an application that allows the users to be prompted to enter first name, last name, scores of test1, scores of test2 and scores of test3. Then display the information in the following format, for example:
------------------------------------------------------------------------------
Student: LASTNAME, firstname
Test1: 94
Test2: 97
Test3: 95
Average scores: 95.3
Grade: A
------------------------------------------------------------------------------

You have to define a class named as Student that holds all the information of a student and methods to calculate the the average and grade and at main method in the controlling class, define an object of Student to store information, calculate or display the information.

The application should allow users to continue using the application to calculate and determine the grade of students until the users choose exit to terminate the program.

My Student Class:

//Import the following
import java.util.*;

public class Student {


String firstName;
String lastName;
String Grade;
double test1;
double test2;
double test3;
double Average;

//2- argument constructor
public Student(String first, String last)
{
firstName = first;
lastName = last;

}

//Begin method setfirstName
public void setfirstName(String first)
{
firstName = first;
}

//Begin method setlastName
public void setlastName(String last)
{
lastName = last;
}

//Begin method getfirstName
public String getfirstName()
{
return firstName;
}

//Begin method getlastName
public String getlastName()
{
return lastName;
}

public void displayMessage()
{
System.out.println("This program will calculate the average of your three test grades");
}
public void determineAverages()
{
Scanner input = new Scanner (System.in);
System.out.println(" ");
System.out.println("Enter -1 for the first test score to exit entry");
System.out.println(" ");

while (test1 != -1)
{
System.out.println("Please input your first name");
firstName = input.nextLine();

System.out.println("Please input your last name");
lastName = input.nextLine();

System.out.println("Please input your first test score");
test1 = input.nextDouble();

System.out.println("Please input your second test score");
test2 = input.nextDouble();

System.out.println("Please input your third test score");
test3 = input.nextDouble();
}

}//End of method determineAverages

public double calAverage()
{
Average= (test1 + test2 + test3)/3.0;
return Average;
}

public String letterGrade (double calAverage)
{
String Grade="null";
if (calAverage >=90.0)
{Grade = "A";}
else if (calAverage >=80.0)
{Grade = "B";}
else if (calAverage >=70.0)
{Grade = "C";}
else if (calAverage >=60.0)
{Grade = "D";}
else if (calAverage < 60.0)
{Grade = "F";}

return Grade;

}

@Override
public String toString()
{
return String.format("%s: %s %s %s: %.1f %s: %.1f %s: %.1f %s: %.1f %s: %s",
"Student", lastName, firstName,
"Test1", test1,
"Test2", test2,
"Test3", test3,
"Average", Average,
"Grade", Grade );
}//End method toString
}

My Main Class (test class):



public class Grade_Application_Last {


public static void main(String[] args) {

Student newStudent = new Student(null, null);
newStudent.displayMessage();
newStudent.determineAverages();

}

}

I cannot figure out what to do next to store and output the names as required. Any help would be greatly appreciated!

Explanation / Answer

please rate - thanks

message me if any problems.

I think this is what you want

import java.util.*;
public class Grade_Application_Last {


public static void main(String[] args) {
Scanner in=new Scanner(System.in);
do
{
Student newStudent = new Student(null, null);
newStudent.displayMessage();
newStudent.determineAverages();
newStudent.calAverage();
newStudent.letterGrade();
System.out.println(newStudent);
System.out.println("------------------------------");
System.out.print("do you have another student(y/n)?");
}while(in.nextLine().toUpperCase().equals("Y") );
}
}

---------------------------------------------


//Import the following
import java.util.*;

public class Student {


String firstName;
String lastName;
String Grade;
double test1;
double test2;
double test3;
double Average;

//2- argument constructor
public Student(String first, String last)
{
firstName = first;
lastName = last;

}

//Begin method setfirstName
public void setfirstName(String first)
{
firstName = first;
}

//Begin method setlastName
public void setlastName(String last)
{
lastName = last;
}

//Begin method getfirstName
public String getfirstName()
{
return firstName;
}

//Begin method getlastName
public String getlastName()
{
return lastName;
}

public void displayMessage()
{
System.out.println("This program will calculate the average of your three test grades");
}
public void determineAverages()
{
Scanner input = new Scanner (System.in);
System.out.println(" ");

System.out.println("Please input your first name");
firstName = input.nextLine();

System.out.println("Please input your last name");
lastName = input.nextLine();

System.out.println("Please input your first test score");
test1 = input.nextDouble();

System.out.println("Please input your second test score");
test2 = input.nextDouble();

System.out.println("Please input your third test score");
test3 = input.nextDouble();


}//End of method determineAverages

public void calAverage()
{
Average= (test1 + test2 + test3)/3.0;
}

public void letterGrade ()
{
if (Average >=90.0)
{Grade = "A";}
else if (Average >=80.0)
{Grade = "B";}
else if (Average >=70.0)
{Grade = "C";}
else if (Average >=60.0)
{Grade = "D";}
else if (Average < 60.0)
{Grade = "F";}

}

@Override
public String toString()
{
return String.format("%s: %s %s %s: %.1f %s: %.1f %s: %.1f %s: %.1f %s: %s",
"Student", lastName, firstName,
"Test1", test1,
"Test2", test2,
"Test3", test3,
"Average", Average,
"Grade", Grade );
}//End method toString
}