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
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): void + + +getScore1(): 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.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started