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

The language is Java, no UML diagram is needed just a working program with neces

ID: 3585524 • Letter: T

Question


The language is Java, no UML diagram is needed just a working program with necessary objects

(The Student class) Design a class named Student that contains: . A private String data field named Name for the student (default "No Name") . A private double data field named Testl for the student (default 0.0) . A private double data field named Test2 for the student (default 0.0) .A private double data field named Test3 for the student (default 0.0) . A no-arg constructor that creates a default student. .A constructor that creates an student with the specified Name, Testl, Test2, and test3 . The accessor and mutator methods for Name, Testl, Test2, and test3. . A method named get Average0 that returns the average of three tests (Testl,Test2, and Test3) Draw the UMl diagram for the class. Implement the class. Write a test program that creates a Student object. Use Scanner object to enter (name,.test I,test2,and test3). Use mutator methods to initialize student class reference variables. Use accessor methods to display name, testl, test2, test3, and average

Explanation / Answer

public class Student{
   //Declare variables
   private String Name;
   private double Test1;
   private double Test2;
   private double Test3;
  
   //default Constructor
   public Student(){
       this.Name = "No Name";
       this.Test1 = 0.0;
       this.Test2 = 0.0;
       this.Test3 = 0.0;
   }
  
   //Constructor with arguments
   public Student(String Name,double Test1,double Test2, double Test3){
       this.Name = Name;
       this.Test1 = Test1;
       this.Test2 = Test2;
       this.Test3 = Test3;
   }
  
   //setter methods
   public void setName(String Name){
       this.Name = Name;
   }
   public void setTest1(double Test1){
       this.Test1 = Test1;
   }
   public void setTest2(double Test2){
       this.Test2 = Test2;
   }
   public void setTest3(double Test3){
       this.Test3 = Test3;
   }

   //getter methods      
   public String getName(){
       return this.Name;
   }
   public double getTest1(){
       return this.Test1;
   }
   public double getTest2(){
       return this.Test2;
   }
   public double getTest3(){
       return this.Test3;
   }

   //average method
   public double getAverage(){
       return (this.Test1 + this.Test2 + this.Test3)/3.0;
   }

   //main method
   public static void main(String args[]){
       Student s = new Student("Student Name",1.0,2.0,3.0);
       System.out.println("Average : "+s.getAverage());
   }
}
/* sample output
Average : 2.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote