I will provide project 3, the demo, and the Name class. I just need the rest add
ID: 3642394 • Letter: I
Question
I will provide project 3, the demo, and the Name class. I just need the rest added.Here is the main assignment:
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;
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) {
Name answer = new Name();
answer.firstName = n.firstName;
answer.middleName = n.middleName;
answer.lastName = this.lastName + "-" + n.lastName;
return answer;
}
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() {
Scanner sc = new Scanner(System.in);
setFirstName(sc.next());
setMiddleName(sc.next());
setLastName(sc.next());
}
}