Hello I'm having a bit of trouble with this assignment. Any help would be appreciated!
Overview
You must implement a Java class which simulates a Student object. These Student objects will represent grade records for students.
Variable Details
name : private String : represents the Student’s name
sid: private String : represents the Student’s ID number
quizzes: private double[] : an array whose size is equal to NUM_QUIZZES. Each element will be used to store one of the student’s quiz scores. For example, if quizzes[0] is set to 19.5, this would mean that the student scored 19.5 points on the first quiz.
exams: private double[] : an array whose size is equal to NUM_EXAMS. Each element will be used to store one of the student’s exam scores. If exams[0] is set to 46.5, this would mean that the student scored 46.5 points on the Midterm. If exams[1] is set to 44.2, this would mean that the student scored 44.2 points on the final.
NUM_QUIZZES: public final static int : represents the number of quizzes given over the course of the semester. This variable should be set to 4.
NUM_EXAMS: public final static int: represents the number of exams given over the course of the semester. This variable should be set to 2 (midterm and final).
QUIZ_MAX_POINTS: public final static int: represents the maximum number of points a student can score on a quiz. This variable should be set to 20.
MIDTERM_MAX_POINTS: public final static int: represents the maximum number of points a student can score on the midterm. This variable should be set to 50.
FINAL_MAX_POINTS: public final static int: represents the maximum number of points a student can score on the final. This variable should be set to 70.
Constructor Methods
Student(): A Student constructor with no parameters. This sets the Student’s name to “NewStudent, A.” and sets the Student’s sid to “0000000”. This also initializes quizzes and exams.
Student(newName: String): A Student constructor overload with one parameter that represents the name of the student. This sets name equal to the argument newName and sid to “0000000”. This also initializes quizzes and exams.
Student(newName: String, newSid: String): A Student constructor overload with two parameters representing the name and ID of the student. This set name equal to the argument newName and sid equal to the argument newSid. This also initializes quizzes and exams.
Other Methods
setName(newName: String): Returns void. Has one String parameter representing the name of the student. This method must first verify that newName follows the correct pattern. A valid name has more than one character, contains a comma followed by a space bar, and ends with a ‘.’ (period) character. If newName meets all three criteria, name will be set to newName; otherwise, a message stating that newName was not in the correct format and therefore could not update name should be displayed. If newName is invalid and name is null, name should be set to “NewStudent, A.”.
getName(): Returns a String. Has no parameters. This method returns name.
setSid(newSid: String): Returns void. Has one String parameter representing the ID of the student. This method must first verify that newSid follows the correct pattern. A valid ID is seven characters in length and contains only digit characters. If newName meets both criteria, sid will be set to newSid; otherwise, a message stating that newSid was not in the correct format and therefore could not update sid should be displayed. If newSid is invalid and sid is null, sid should be set to “0000000”.
getSid(): Returns a String. Has no parameters. This method returns sid.
setQuiz(quizNumber: int, score: double): Returns void. Has one int parameter representing a quiz number and one double parameter representing the student’s score for that quiz. This method must first check to ensure that quizNumber is a value between 1 and NUM_QUIZZES. The method must also check to ensure that score is a value between 0 and QUIZ_MAX_POINTS. If both criteria are met, the method sets quizzes[quizNumber - 1] equal to score; otherwise, the method should display a message stating that the quiz could not be set.
getQuiz(quizNumber: int): Returns and int. Has one parameter representing a quiz number. This method must first check to ensure that quizNumber is a number between 1 and NUM_QUIZZES. If quizNumber meets this criterion, the method will return the value quizzes[quizNumber - 1]. Otherwise, the method returns a -1.
setMidtermExam(score: double): Returns void. Has one parameter representing the student’s score on the midterm. This method must first check to ensure that score is a value between 0 and MIDTERM_MAX_POINTS. If score meets this criterion, then exams[0] is set equal to score; otherwise, the method should display a message stating that the midterm exam score could not be set.
getMidtermExam(): Returns a double. Has no parameters. This method returns exams[0].
setFinalExam(score: double): Returns void. Has one double parameter representing the student’s score on the final. This method must first check to ensure that score is a value between 0 and FINAL_MAX_POINTS. If score meets this criterion, then exams[1] is set equal to score; otherwise, a message stating that the final exam score could not bet set should be displayed. getFinalExam(): Returns a double. Has no parameters. This method returns exams[1].
toString(): Returns a String. Has no parameters. This method should return a String that represents this Student object. The returned String should include the Student’s name, the Student’s ID, the Student’s four quiz scores, and the Student’s two exam scores concatenated into one String.
Please find the java class program below
Note: file name should be in Main.java.
Program:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//student class
class Student {
public
final static int NUM_EXAMS = 2;
final static int NUM_QUIZZES = 4;
final static int QUIZ_MAX_POINTS = 20;
final static int MIDTERM_MAX_POINTS = 50;
final static int FINAL_MAX_POINTS = 70;
private
String name;
String sid;
double quizzes[] = new double[NUM_QUIZZES];
double exams[] = new double[NUM_EXAMS];
public Student()
{
this.name = "NewStudent, A.";
this.sid = "0000000";
for (int i=0; i<NUM_QUIZZES; i++)
{
this.quizzes[i]=0;
}
for (int i=0; i<NUM_EXAMS; i++)
{
this.exams[i]=0;
}
}
public Student(String name)
{
this.name = name;
this.sid = "0000000";
for (int i=0; i<NUM_QUIZZES; i++)
{
this.quizzes[i]=0;
}
for (int i=0; i<NUM_EXAMS; i++)
{
this.exams[i]=0;
}
}
public Student(String name, String sid)
{
this.name = name;
this.sid = sid;
for (int i=0; i<NUM_QUIZZES; i++)
{
this.quizzes[i]=0;
}
for (int i=0; i<NUM_EXAMS; i++)
{
this.exams[i]=0;
}
}
public void setName(String name)
{
String pattern = ".*, .*.$";
if(Pattern.matches(".*, .*\\.$",name))
{
this.name=name;
}
else
{
System.out.println("Student name doesn't match the
criteria.\n");
}
}
public String getName()
{
return this.name;
}
public void setSid(String sid)
{
if(Pattern.matches("[0-9][0-9][0-9][0-9][0-9][0-9][0-9]",sid))
{
this.sid=sid;
}
else
{
System.out.println("Student Id doesn't match the
criteria.\n");
}
}
public String getSid()
{
return this.sid;
}
public void setQuiz(int qno, double score)
{
if(qno >= 1 && qno <= NUM_QUIZZES && score
<= QUIZ_MAX_POINTS && score >= 0 )
{
this.quizzes[qno-1]=score;
}
else
{
System.out.println("Quiz score couldn't be set.\n");
}
}
public double getQuiz(int qno)
{
if(qno >= 1 && qno <= NUM_QUIZZES)
{
return this.quizzes[qno-1];
}
else
{
return -1;
}
}
public void setMidtermExam(double score)
{
if(score >= 0 && score <= MIDTERM_MAX_POINTS)
{
this.exams[0]=score;
}
else
{
System.out.println("Mid term score could not be set.\n");
}
}
public double getMidtermExam()
{
return this.exams[0];
}
public void setFinalExam(double score)
{
if(score >= 0 && score <= FINAL_MAX_POINTS)
{
this.exams[1] = score;
}
else
{
System.out.println("Final score could not be set.\n");
}
}
public double getFinalExam()
{
return this.exams[1];
}
public String toString()
{
//do concatenation and print the values
return this.name +", "+this.sid +", "+this.quizzes[0] +
", "+this.quizzes[1]+", "+this.quizzes[2]+", "+this.quizzes[3]
+
", "+this.exams[0] +", "+this.exams[1];
}
}
public class Main
{
public static void main(String[] args) {
Student S1 = new Student();
Student S2 = new Student();
System.out.println("successs case output.");
//successs case
S1.setName("Kyrie, I.");
System.out.println(S1.getName());
S1.setSid("1234567");
System.out.println(S1.getSid());
//setting all the quiz value as right values
S1.setQuiz(1, 20);
S1.setQuiz(2, 5);
S1.setQuiz(3, 15);
S1.setQuiz(4,0);
System.out.println("Score 1:" + S1.getQuiz(1));
System.out.println("Score 2:" + S1.getQuiz(2));
System.out.println("Score 3:" + S1.getQuiz(3));
System.out.println("Score 4:" + S1.getQuiz(4));
S1.setMidtermExam(20);
System.out.println("Mid Term score: " + S1.getMidtermExam());
S1.setFinalExam(70);
System.out.println("Mid Term score: " + S1.getFinalExam());
System.out.println(S1.toString());
//failure case
System.out.println("failure case output.");
S2.setName("Kuyrie, I");
S2.getName();
S1.setSid("123456S");
System.out.println(S2.getSid());
//setting all the quiz value as right values
S2.setQuiz(0, 21);
S2.setQuiz(2, -1);
S2.setQuiz(3, 15);
S2.setQuiz(5,3);
System.out.println("Score 1:" + S2.getQuiz(1));
System.out.println("Score 2:" + S2.getQuiz(2));
System.out.println("Score 3:" + S2.getQuiz(3));
System.out.println("Score 4:" + S2.getQuiz(4));
S2.setMidtermExam(-1);
S2.setMidtermExam(60);
System.out.println("Mid Term score: " + S2.getMidtermExam());
S2.setFinalExam(90);
S2.setFinalExam(-1);
System.out.println("Mid Term score: " + S2.getFinalExam());
System.out.println(S2.toString());
}
}
Output:
successs case output.
Kyrie, I.
1234567
Score 1:20.0
Score 2:5.0
Score 3:15.0
Score 4:0.0
Mid Term score: 20.0
Mid Term score: 70.0
Kyrie, I., 1234567, 20.0, 5.0, 15.0, 0.0, 20.0, 70.0
failure case output.
Student name doesn't match the criteria.
Student Id doesn't match the criteria.
0000000
Quiz score couldn't be set.
Quiz score couldn't be set.
Quiz score couldn't be set.
Score 1:0.0
Score 2:0.0
Score 3:15.0
Score 4:0.0
Mid term score could not be set.
Mid term score could not be set.
Mid Term score: 0.0
Final score could not be set.
Final score could not be set.
Mid Term score: 0.0
NewStudent, A., 0000000, 0.0, 0.0, 15.0, 0.0, 0.0, 0.0
Screen Shot:








Hello I'm having a bit of trouble with this assignment. Any help would be appreciated! Overview...
Within DrJava, create a class called StudentQuizScores and do the following using a do-while loop. 1. You program will read in a student’s first name. The same will be done for the student’s last name. Your program will use respective methods (described below) to accomplish this. 2. Your program will then read in three quiz scores, respectively. This should be done by using the same method three times. This method is described below. 3. Your program will then calculate the...
Write a grading program in Java for a class with the following grading policies: There are three quizzes, each graded on the basis of 10 points. There is one midterm exam, graded on the basis of 100 points. There is one final exam, graded on the basis of 100 points. The final exam counts for 40% of the grade. The midterm counts for 35% of the grade. The three quizzes together count for a total of 25% of the grade....
Write a class called Student. The specification for a Student is: Three Instance fields name - a String of the student's full name totalQuizScore - double numQuizesTaken - int Constructor Default construtor that sets the instance fields to a default value Parameterized constructor that sets the name instance field to a parameter value and set the other instance fields to a default value. Methods setName - sets or changes the student name by taking in a parameter getName - returns...
I am having trouble getting this program to run with 3 parts. Could I get assistance to understand this code as well? Here is the information given. 7.20 Chapter 7A Create the class described by the UML and directions are given below: Student - studentName: string - midterm: int - finalGrade: int +Student() +Student(name: string, midterm: int, fin: int) +setMidterm(grade: int): void +setFinal(grade: int): void + setStudentName(studentName: string): void +getName():String +getMidterm():int +getFinal():int +computeAverage(): double +computeLetterGrade(): string +printGradeReport():void Create the class...
Your assignment is to write a grade book for a teacher. The
teacher has a text file, which includes student's names, and
students test grades. There are four test scores for each student.
Here is an example of such a file:
Count: 5
Sally 78.0 84.0 79.0 86.0
Rachel 68.0 76.0 87.0 76.0
Melba 87.0 78.0 98.0 88.0
Grace 76.0 67.0 89.0 0.0
Lisa 68.0 76.0 65.0 87.0
The first line of the file will indicate the number of students...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...
Hi, I am having trouble solving the constructor, it requires to ArrayList marks to be a deep copy of the instance variable. I have also provided the J-Unit test I have been provided. import java.util.*; public class GradebookEntry { private String name; private int id; private ArrayList<Double> marks; /** * DO NOT MODIFY */ public String toString() { String result = name+" (ID "+id+")\t"; for(int i=0; i < marks.size(); i++) { /** * display every mark rounded off to two...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
Program 7 Arrays: building and sorting (100 points) Due: Friday, October 30 by 11:59 PM Overview For this assignment, write a program that will calculate the quiz average for a student in the CSCI 240 course. The student's quiz information will be needed for later processing, so it will be stored in an array. For the assignment, declare one array that will hold a maximum of 12 integer elements (ie. the quiz scores). It is recommended that this program be...