Question

public class StudentADT { //1. A Student class should include data attributes including a // student’s...

public class StudentADT { //1. A Student class should include data attributes including a // student’s name (first, and last), a student number, //an array of 3 assignment grades, and an exam grade. private String firstName; private String lastName; private int studentNumber; private double[] assignmentGrades; private double examGrade; //the constructor StudentADT(firstNm, lastNm, stNo, asn1Grade, asn2Grade, asn3Grade, examGrade) public StudentADT(String firstNm, String lastNm, int stNo, double asn1Grade, double asn2Grade, double asn3Grade, double examGrade) { firstName = firstNm; lastName = lastNm; studentNumber = stNo; assignmentGrades = new double[3]; assignmentGrades[0] = asn1Grade; assignmentGrades[1] = asn2Grade; assignmentGrades[2] = asn3Grade; this.examGrade = examGrade; } //displayStudentRecord() – displays the student record on the console void displayStudentRecord() { System.out.println("Student Name: " + firstName + " " + lastName); System.out.println("Student Number: " + studentNumber); System.out.println("Assignment Grades -"); System.out.println("Assignment Grade 1: " + assignmentGrades[0]); System.out.println("Assignment Grade 2: " + assignmentGrades[1]); System.out.println("Assignment Grade 3: " + assignmentGrades[2]); System.out.println("Exam Grade: " + examGrade); } //changeAssignmentGradeForStudent (asnNum, grade) – adds a given number // grade to the grade of a given assignment number asnNum void changeAssignmentGradeForStudent(int asnNum, double grade) { if (asnNum == 1) { assignmentGrades[0] = grade; } else if (asnNum == 2) { assignmentGrades[1] = grade; } else if (asnNum == 3) { assignmentGrades[2] = grade; } else { System.out.println("Incorrect Assignment Number entered"); } } //changeExamGradeForStudent(grade) – adds a given number grade to the final // exam grade void changeExamGradeForStudent(double grade){ this.examGrade=grade; } } _________________________________________________________________________________________ //Exercise 2 A Student ADT test application (10 pts) public class StudentADTTester { public static void main(String[] args) { //Your algorithm creates at least one student record. StudentADT studentADT = new StudentADT("Jacob","Moses",4, 89,87,92,95); //Your algorithm calls each function at least once. studentADT.displayStudentRecord(); studentADT.changeAssignmentGradeForStudent(2,99); studentADT.changeExamGradeForStudent(98); //Your algorithm would present evidence that your // functions are working correctly or not. System.out.println("Student Name should print Jacob Moses"); System.out.println("Student Number should print 4"); System.out.println("Assignment 1 should print 89"); System.out.println("Assignment 2 should print 99 instead of 87"); System.out.println("Assignment 3 should print 92-"); System.out.println("Exam Grade should print 98 instead of 95"); studentADT.displayStudentRecord(); } }\

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have corrected the syntax error and ran the program, refer the screenshot for the output

___________________________________________________________________________________________________

public class StudentADT {
   // 1. A Student class should include data attributes including a
   // student’s name (first, and last), a student number,
   // an array of 3 assignment grades, and an exam grade.
   private String firstName;
   private String lastName;
   private int studentNumber;
   private double[] assignmentGrades;
   private double examGrade;

   // the constructor StudentADT(firstNm, lastNm, stNo, asn1Grade,
   // asn2Grade,asn3Grade, examGrade)

   public StudentADT(String firstNm, String lastNm, int stNo, double asn1Grade, double asn2Grade, double asn3Grade,double examGrade) {
       firstName = firstNm;
       lastName = lastNm;
       studentNumber = stNo;
       assignmentGrades = new double[3];
       assignmentGrades[0] = asn1Grade;
       assignmentGrades[1] = asn2Grade;
       assignmentGrades[2] = asn3Grade;
       this.examGrade = examGrade;
   }

   // displayStudentRecord() – displays the student record on the console
   void displayStudentRecord() {
       System.out.println("Student Name : " + firstName + " " + lastName);
       System.out.println("Student Number: " + studentNumber);

       System.out.println("Assignment Grades -");
       System.out.println("Assignment Grade 1: " + assignmentGrades[0]);
       System.out.println("Assignment Grade 2: " + assignmentGrades[1]);
       System.out.println("Assignment Grade 3: " + assignmentGrades[2]);
       System.out.println("Exam Grade: " + examGrade);
   }

   // //changeAssignmentGradeForStudent (asnNum, grade) – adds a given number //
   // grade to the grade of a given assignment number asnNum
   void changeAssignmentGradeForStudent(int asnNum, double grade) {
       if (asnNum == 1) {
           assignmentGrades[0] = grade;
       } else if (asnNum == 2) {
           assignmentGrades[1] = grade;
       } else if (asnNum == 3) {
           assignmentGrades[2] = grade;
       } else {
           System.out.println("Incorrect Assignment Number entered");
       }
   }

   // //changeExamGradeForStudent(grade) – adds a given number grade to the final
   // // exam grade
   void changeExamGradeForStudent(double grade) {
       this.examGrade = grade;
   }
}
____________________________________________________________________________________________

public class StudentADTTester {

   public static void main(String[] args) {

       // Your algorithm creates at least one student record.
       StudentADT studentADT = new StudentADT("Jacob", "Moses", 4, 89, 87, 92, 95);
       // Your algorithm calls each function at least once.
       studentADT.displayStudentRecord();
       studentADT.changeAssignmentGradeForStudent(2, 99);
       studentADT.changeExamGradeForStudent(98);
       // Your algorithm would present evidence that your
       // functions are working correctly or not.
       System.out.println("Student Name should print Jacob Moses");
       System.out.println("Student Number should print 4");
       System.out.println("Assignment 1 should print 89");
       System.out.println("Assignment 2 should print 99 instead of 87");
       System.out.println("Assignment 3 should print 92");
       System.out.println("Exam Grade should print 98 instead of 95");
       studentADT.displayStudentRecord();
   }
}

______________________________________________________________________________________________

image screenshot

Add a comment
Know the answer?
Add Answer to:
public class StudentADT { //1. A Student class should include data attributes including a // student’s...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • using basic c++ please!!! 6. (21%) Consider the following definitions class Student { class Section public:...

    using basic c++ please!!! 6. (21%) Consider the following definitions class Student { class Section public: string getFirst (); string getLast (); intgetGrade () void setFirst (string s); void setLast (string s); void setGrade(int g); numStudents (); in Student getNthStudent (int n); string getCourse (); string getInstructor (); private: private: string firstName; string lastName; int Student students [SIZE]; string course; string instructor; grade ; Write a function, honorRoll that returns a dynamic array containing only those students in section sec...

  • CSCI 135 Test 2 Name: 6, (21%) Consider the following definitions: class Student class Section public:...

    CSCI 135 Test 2 Name: 6, (21%) Consider the following definitions: class Student class Section public: string getFirst ) string getLast () int getGrade) void set First (string s) void setLast (string ) void setGrade (nt g): numStudents () Student getNthStudent (int n) string getCourse ) string getInstructor ); private: private: string firstName string lastName Student students [SIZE: string course; string structor; grade; Write a function, honorRoll that returns a dynamic array containing only those students in section sec with...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

  • FOR JAVA: Summary: Create a program that adds students to the class list (see below). The...

    FOR JAVA: Summary: Create a program that adds students to the class list (see below). The solution should be named Roster402_v2.java. Allow the user to control the number of students added to the roster. Ask if the user would like to see their new roster to confirm additions. If yes, then display contents of the file, if no, end the program. ------------------------------------------------------------------------------------- List of student names and IDs for class (this will be your separate text file): Jones, Jim,45 Hicks,...

  • I have a little problem about my code. when i'm working on "toString method" in "Course"...

    I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student {    private String firstName;    private String lastName;    private String id;    private boolean tuitionPaid;       public Student(String firstName, String lastName, String id, boolean tuitionPaid)    {        this.firstName=firstName;        this.lastName=lastName;        this.id=id;        this.tuitionPaid=tuitionPaid;    }   ...

  • import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {   ...

    import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {        Student s1 = new Student();         Student s2 = new Student("Smith", "123-45-6789", 3.2);         Student s3 = new Student("Jones", "987-65-4321", 3.7);         System.out.println("The name of student #1 is ");         System.out.println("The social security number of student #1 is " + s1.toString());         System.out.println("Student #2 is " + s2);         System.out.println("the name of student #3 is " + s3.getName());         System.out.println("The social security number...

  • using C++ language!! please help me out with this homework In this exercise, you will have...

    using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...

  • Hello, Can you please error check my javascript? It should do the following: Write a program...

    Hello, Can you please error check my javascript? It should do the following: Write a program that uses a class for storing student data. Build the class using the given information. The data should include the student’s ID number; grades on exams 1, 2, and 3; and average grade. Use appropriate assessor and mutator methods for the grades (new grades should be passed as parameters). Use a mutator method for changing the student ID. Use another method to calculate the...

  • NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the...

    NETBEANS JAVA BANK PROGRAM (TAKE SCREENSHOTS FROM NETBEANS INCLUDING OUTPUT PLEASE) Display the accounts for the current displayed customer PLEASEEEEEEEEEE package bankexample; import java.util.UUID; public class Customer { private UUID id; private String email; private String password; private String firstName; private String lastName;    public Customer(String firstName, String lastName, String email, String password) { this.id = UUID.randomUUID(); this.firstName = firstName; this.lastName = lastName; this.email = email; this.password = password; } public String getFirstName() { return firstName; } public void setFirstName(String...

  • Hello, How can I make the program print out "Invalid data!!" and nothing else if the...

    Hello, How can I make the program print out "Invalid data!!" and nothing else if the file has a grade that is not an A, B, C, D, E, or F or a percentage below zero? I need this done by tomorrow if possible please. The program should sort a file containing data about students like this for five columns: one for last name, one for first name, one for student ID, one for student grade percentage, one for student...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT