Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ICS 141. Programming with Objects. Lab 2. Your Name: Points: 15 Points earned: You must attempt to complete the lab during lab time. If cannot,
ICS 141. Programming with Objects. Lab 2. Your Name: Points: 15 Points earned: You must attempt to complete the lab during lab time. If cannot, you may work on it outside and submit it by the beginning of the next class. But I will allow that only if you work on the problem in the assigned lab time. You may work alone or in a group of two. Your score will depend on how far you are able to complete the work and the correctness of the work. In this lab, you are asked to do Java programming use Java basic execution flow constructs. Goals: To learn Java basic execution flow constructs (selections and loops), static methods. The Problem Statement In this lab section, you are going to learn how to use loop statements. You are going to write an application that has two classes. Each of these classes may have multiple methods. One method may call another method within the same class. This application will calculate the average score for a test taken by the students. It will ask user to input the a number of entries. For each entry, the user will input a test score (see Test Case 1 for detailed input values). Then the application will calculate the average score and output the result. You need to use the following test data when you do a screen capture. Test Case 1 Input: Welcome to ICS 141 Lab 2. Number of entries: 3 Score1: 70 Score2: 90 Score3: 100 Output: The average score for your inputs is: Il you figure out The Design This is a relatively simple application. Thus we are going to use two classes to implement this application. The worker class is named GradeAverage and the application class is named TestGradeAverage. The member information of the two classes is: TestGrade Average main Grade Average double: average Score Grade Averagel Il constructor static int readinto void calculate Grade Average double getGradeAverage The relationship of the two classes is: TestGrade Average uses Grade Average. The readint method is a static method. This method reads an integer from the standard input (keyboard). SCORE YOUR POINTS BY DOING THE FOLLOWING According to the information given above, draw a class diagram in the space below (using UML notation) (4 pts). Programming work In this section, you are asked to implement the above design and do some screen captures of the outputs. You are given partial code and you need to finish the missing code according to the requirements. Specifically, you are given the following code: class Grade Average Application class TestGrade Average And you need to supply the missing code for the following class methods: calculate GradeAxerade in Grade Average getGrade Average in Grade Average The following is the partial code for this application: import javax.swing.*; public class Gred Average 1 private double axesags SCORE public Gede Average) { seragascare. - 0; private static int readint (String prompt) ( String austr = Jhettenkane showinnutdiateg (prompt); return Integerularestat (Dunst); public void satsutate Gradeavesags1 { int owoberEntries = seadot ("Number of entries: "); int score; 1/ supply the body of this method // This method uses for-loop to receive Il n integers from the user by calling 1/ readint 1) n times. Here, n equals to the 1/ numberEntries. This method also calculates // and sets the instance variable average Score // to the appropriate value. public double getGradeaverage) { // supply the body of this method // This method returns the instance variable 11 average Score public class Test Grade Axszeget public static void main(String[] args) { Grade Average grade average = new Grade Average); Systemout.println("Welcome to ICS 141 Lab 2."); gradeaverage calculateGradeAverage(): System.out.println("The average score for your inputs is: " + grade Average.getGrade Avecage()); SCORE YOUR POINTS BY DOING THE FOLLOWING Cut and paste the Java source code for the method calculateGradeAverage.java in the space below (4 pts): Cut and paste the Java source code for the method getGradeAverage.java in the space below (2 pts): Cut and paste the output in the space below (5 pts)
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