Question: Please ilistrate a UML diagram for the following code below, it should have 3 rows, 1 colum like the example below. First box should have

Please ilistrate a UML diagram for the following code below, it should have 3 rows, 1 colum like the example below. First box should have the class name, second box is for class attributes, and the third box should have the class operations/methods and please put a (+) for public and a (-) for private, also each diagram pointing to the appropriate classes with arrows, Thank you so much!

Class

+- Attributes
+-Operations

class TestScores

{ private int scores[]=new int[5]; public TestScores(int test[]) { //to validate input test score

try { for(int i=0;i<5;i++) {

if (test[i]<0||test[i]>100) //condition //Throws an exception when test score is (Score <0 || score>100) throw new IllegalArgumentException("Number cannot" +

" be less than 0 and greater than 100"); else

scores[i]=test[i]; }

//function call to print average

System.out.println("Your Average Test Score is:"+Average()); }

catch(IllegalArgumentException e) { System.out.println(e); } }

//function average

public double Average() { //variable initialized to 0 int sum=0; double avg; for(int i=0;i<5;i++) { sum+=scores[i]; } avg=sum/5;

return avg;

}//end Average

}//end TestScores class

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

import java.util.Scanner; class TestScoresDemo { public static void main(String args[]) throws Exception

{ Scanner kb = new Scanner(System.in); int array[]=new int[5];//array declaration //inputting test scores System.out.println("Please Enter TestScores"); for(int i=0;i<5;i++)

array[i]=kb.nextInt();//Reading array of TestScores

//Creating instance to class TestScore

TestScores t1=new TestScores(array);

System.exit(0);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!