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

Here is the main assignment but I will provide project 3, the demo, and the Name

ID: 3642501 • Letter: H

Question

Here is the main assignment but I will provide project 3, the demo, and the Name class. I just need the rest added.

Do project 3. I will provide a main program as the demo. Use the Name class to give the student a name. When prompting for input check to make sure the grades are in an appropriate range, and use a while loop to get another input value until it is in range.

Project 3:
public class Project3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the score for quiz 1: ");
double quiz1 = in.nextDouble();
System.out.print("Enter the score for quiz 2: ");
double quiz2 = in.nextDouble();
System.out.print("Enter the score for the midterm: ");
double midterm = in.nextDouble();
System.out.print("Enter the score for the final: ");
double finalExam = in.nextDouble();
double score = (quiz1 + quiz2) * 1.25 + (midterm * .25) + (finalExam * .5);
System.out.println("Quiz 1: " + (quiz1 * 10) + "%");
System.out.println("Quiz 2: " + (quiz2 * 10) + "%");
System.out.println("Midterm: " + midterm + "%");
System.out.println("Final: " + finalExam + "%");
System.out.println("Total score for course: " + score + "%");
System.out.print("Final letter grade: ");
if(score >= 90) {
System.out.println("A");
}
else if(score >= 80) {
System.out.println("B");
}
else if(score >= 70) {
System.out.println("C");
}
else if(score >= 60) {
System.out.println("D");
}
else {
System.out.println("F");
}
}
}

Main program as demo:

import java.util.Scanner;
public class StudentDemo {
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
Student person = new Student (); // one Student
int numberOfStudents, i;
System.out.println("Enter number of Students:");
numberOfStudents = scan.nextInt( );
for(i = 0; i < numberOfStudents; i++)
{
person.readInput();
person.calculateGrade();
person.writeOutput();
}

Here is the Name class:

import java.util.Scanner;
public class Name
{

private String firstName,middleName,lastName;
Scanner keyboard = new Scanner(System.in);

public Name()
{
firstName="";
middleName="";
lastName="";
}
public Name(String f,String l)
{
firstName=f;
middleName="";
lastName=l;
}
public Name(String f, String m, String l)
{
firstName=f;
middleName=m;
lastName=l;
}
public String getFirstName()
{
return firstName;
}
public String getMiddleName()
{
return middleName;
}
public String getLastName()
{
return lastName;
}
public void setFirstName(String f)
{
firstName=f;
}
public void setMiddleName(String m)
{
middleName=m;
}
public void setLastName(String l)
{
lastName=l;
}
public void changeNameTo(String f, String m, String l)
{
firstName=f;
middleName=m;
lastName=l;
}
public void changeNameTo(Name n)
{
firstName=n.getFirstName();
middleName=n.getMiddleName();
lastName=n.getLastName();
}
public Name add(Name n)
{
return new Name(n.getFirstName(),n.getMiddleName(),lastName+"-"+n.getLastName());
}
public String getFullNameToUpperCase()
{
return (toString()).toUpperCase();
}
public String toString()
{
return firstName+" "+middleName+" "+lastName;
}
public boolean equals(Name n)
{
return firstName.equals(n.getFirstName());
}
public void readName() {
System.out.println("Please enter first name");
firstName = keyboard.nextLine();
System.out.println("Please enter middle name");
middleName = keyboard.nextLine();
System.out.println("Please enter last name");
lastName = keyboard.nextLine();

}

}

Explanation / Answer

Try this for Program3:


public class Project3 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Enter the score for quiz 1: ");
double quiz1 = 0.0;
do
{
System.out.print("Please enter score: ");
quiz1 = in.nextDouble();

} while(quiz1 < 0 || quiz1 > 100.0);

System.out.print("Enter the score for quiz 2: ");
double quiz2 = 0.0;
do
{
System.out.print("Please enter score: ");
quiz2 = in.nextDouble();

} while(quiz2 < 0 || quiz2 > 100.0);
System.out.print("Enter the score for the midterm: ");
double midterm = 0.0;
do
{
System.out.print("Please enter score: ");
midterm = in.nextDouble();

} while(midterm < 0 || midterm > 100.0);
System.out.print("Enter the score for the final: ");
double finalExam = 0.0;
do
{
System.out.print("Please enter score: ");
finalExam = in.nextDouble();

} while(finalExam < 0 || finalExam > 100.0);
double score = (quiz1 + quiz2) * 1.25 + (midterm * .25) + (finalExam * .5);
System.out.println("Quiz 1: " + (quiz1 * 10) + "%");
System.out.println("Quiz 2: " + (quiz2 * 10) + "%");
System.out.println("Midterm: " + midterm + "%");
System.out.println("Final: " + finalExam + "%");
System.out.println("Total score for course: " + score + "%");
System.out.print("Final letter grade: ");
if(score >= 90) {
System.out.println("A");
}
else if(score >= 80) {
System.out.println("B");
}
else if(score >= 70) {
System.out.println("C");
}
else if(score >= 60) {
System.out.println("D");
}
else {
System.out.println("F");
}
}
}