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

Complete the UML for the TestScore class below with the proper fields/attributes

ID: 3679348 • Letter: C

Question

Complete the UML for the TestScore class below with the proper fields/attributes in the second row, getters and setters methods in the third row.

TestScore

- score1: double

-

-

+

+setScore1(n: double)

+

+

+

+

In the second row, all fields or attributes for this course are private, - score1: double

NOTE: Please do not write an Java code in UML.

Please write the other two fields in second row.

In the third row, write all members here, member are setters/mutators and getters/assessors methods.

NOTE: The first method is default to as constructor method. Please write a TestScore constructor method as the first method with an arguments: double datatype for s1, s2 and s3, then in the body of this method, assign each parameter to the appropriate field.

Write all eight methods in the above UML, in addition the constructor and getAverage() methods. You will need to write three setters and three getters methods for each of the fields. All methods for this course are public +

Using NotePad, create the TestScore class, save as TestScore.java and compile to generate the TestScore.class file.

public class TestScores

{

   //write your fields here for testScore1, testScore2, testScore3 with proper datatype

   /**

    * Constructor

    */

   public TestScores()

   {

     

   }

//---------------------------------------------------------------------------------------------------------------->

   // write all setters methods for setTestScore1, setTestScore2 and setTestScore3 methods below:

   //---------------------------------------------------------------------------------------------------------------->

   //---------------------------------------------------------------------------------------------------------------->

   // write all getters methods for getTestScore1, getTestScore2 and getTestScore3 methods below:         

   //---------------------------------------------------------------------------------------------------------------->

  

   //---------------------------------------------------------------------------------------------------------------->

   // write getAverage method here

   //---------------------------------------------------------------------------------------------------------------->

  

   //---------------------------------------------------------------------------------------------------------------->

   // write getLetterGrade method here

   //---------------------------------------------------------------------------------------------------------------->

   public char getLetterGrade()

   {

      //declare your grade as char and average as double datatypes here

     

      //call the getAverage method and assign to a average here

    

      //use if/else structure for ranges, starting with upper boundaries, use logical and relation operators

      //to avoid nesting of loops.

      

   }

}

Using NotePad, create the TestScoreDemo.java to instantiate the Employee objects for test1, test2, and test3.

// Needed for the Scanner class

public class TestScoresDemo

{

   public static void main(String[] args)

   {

      // Test score #1

      // Test score #2

      // Test score #3

                       

      // Create a Scanner object for keyboard input.

     

     

      // Get three test scores from the user.

     

     

      // Create a TestScores object initialized

      // with the three test scores.

     

     

      // Display the test scores.

      // Display the average test score.

      // Display the letter grade.

   }

}

Compile the TestScoreDemo.java to TestScoreDemo.class and take screen shot of output (Ctrl + Alt + PrtScn) and paste (Ctrl + V) below:

Files include in this directory is TestScore.java, TestScore.java, and both .class files, and this document.

TestScore

- score1: double

-

-

+

+setScore1(n: double)

+

+

+

+

Explanation / Answer

/******************************** TestScores.java **************************************/

class TestScores
{
private double Score1; //For Score 1
private double Score2; //For Score 2
private double Score3; //For Score 3
  
  
public double getScore1()
{
return Score1;
}
  
public double getScore2() //Using the accessor get, to retrieve the
{ // the values stored in the different scores.
return Score2;
}
  
public double getScore3()
{
return Score3;
}
  
public void setScore1( double S1)
{
Score1 = S1;
}
  
public void setScore2(double S2) //Using the accessor set, to set the
{ // the values stored in the different scores.
Score2 = S2;
}
  
public void setScore3(double S3)
{
Score3 = S3;
}
  


public double getAverage() // getAverage Accessor is to retrieve
{ // an average of the 3 test scores
return (Score1+Score2+Score3)/3;
}


public String getLetterGrade()
{
double average = getAverage();

if (average >= 90)
{
return "A";
}
  
else if (average >= 80)
{
return "B";
}
  
else if (average >= 70)
{
return "C";
}
  
else if (average >= 60)
{
return "D";
}
  
else
{
return "F";
}
}
  
}

/***************************** TestScoresDemo.java ***********************/

import java.util.Scanner; //needed for scanner class, to input information.

public class TestScoresDemo
{
   public static void main(String[] args)
   {

       double Score1;
       double Score2;
       double Score3;
      
      
       //creates the scanner object to input information.
       Scanner keyboard = new Scanner(System.in);
  
       //get the first score.  
       System.out.println("What is the first score? ");
       Score1 = keyboard.nextDouble();
      
       //get the second score.
       System.out.println("what is the second score? ");
       Score2 = keyboard.nextDouble();
      
       //get the thrid score.
       System.out.println("What is the thrid score? ");
       Score3 = keyboard.nextDouble();
       //Show the average for all 3 scores


       TestScores scores = new TestScores();
       scores.setScore1(Score1);
       scores.setScore2(Score2);
       scores.setScore3(Score3);

       System.out.println("The Test Scores are: "+ scores.getScore1()+ " "+ scores.getScore2()+" "+ scores.getScore3());

      
       System.out.println("The average of all your tests is: " + scores.getAverage());
       System.out.println("Your Grade is: " + scores.getLetterGrade());
   }
  
}
      

TestScore - Score1: double - Score2: double - Score3: double + setScore1(S1: double) +  setScore2(S2: double) +  setScore3(S3: double) +  getScore1() +  getScore2() +  getScore3() + getAverage() + getLetterGrade()
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