Write a JAVA program that reads a list of 25 values from the user. Put the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a JAVA program that reads a list of 25 values from the user. Put the values in an array. The program should read the array and then calculate and display the average of the even input values and the average of the odd input values. Consideration: You should have a class and a tester. In the class, you will have three instance variable, 1) an array to hold the numbers, 2) a double to hold the odd average and a double to hold the even average. The constructor should accept as input the array from the tester class and assign it to the instant variable; it should also assign 0 to the even and odd average variables. You should then have a method that will read the array and then calculate the average of the even input values and the average of the odd input values. Your program will need a getOddAverage and a getEvenAverage method. The tester class will ask the user to input numbers (consider partially filled as well). It will then create an object passing the filled array to the class. The tester should then call the calculate the averages method. You will then need to print the even and odd average. Write a JAVA program that reads a list of 25 values from the user. Put the values in an array. The program should read the array and then calculate and display the average of the even input values and the average of the odd input values. Consideration: You should have a class and a tester. In the class, you will have three instance variable, 1) an array to hold the numbers, 2) a double to hold the odd average and a double to hold the even average. The constructor should accept as input the array from the tester class and assign it to the instant variable; it should also assign 0 to the even and odd average variables. You should then have a method that will read the array and then calculate the average of the even input values and the average of the odd input values. Your program will need a getOddAverage and a getEvenAverage method. The tester class will ask the user to input numbers (consider partially filled as well). It will then create an object passing the filled array to the class. The tester should then call the calculate the averages method. You will then need to print the even and odd average.
Expert Answer:
Answer rating: 100% (QA)
JAVA CODE import javautil class OddEven int arr2 double avgeven double avgodd public OddEve... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Predictive text entry systems are familiar on touch screens and mobile phones. This question asks you to consider how the same principles might be used in a programming editor for creating Java code....
-
Let r and s be solutions to the quadratic equation x 2 b x + c = 0. For n N, define d0 = 0 d1 = r s dn = b dn1 c dn2 (n 2) Prove that dn = r n s n for all n N. [4 marks] (b) Recall that a commutative...
-
Run experiments to determine the relative costs of Math.exp() and the methods from EXERCISE 1.3.38 for computing e x : the direct method with nested for loops, the improvement with a single for loop,...
-
The Forever Green Nursery has 7000 white pine trees. Each year, the nursery plans to sell 12% of its trees and plant 600 new ones. a. Make a graph that shows the number of trees at the nursery over...
-
Red Hawk Inc., is obligated to pay its creditors $6,800 during the year. a. What is the market value of the shareholders' equity if assets have a market value of $8,700? b. What if assets equal...
-
You are given a timewheel that is initially empty. The timewheel processes events, each of which has a generation time and a release time. Show the state of the timewheel (events and their order)...
-
Design a layout on a 2 x 3 grid that satisfies thesepreferences. Department A Department B Department C Department D Department E O XAXI Department
-
The company in the service sector will be Xcel Energy (XEL). Find the recent set of financial statements (Income Statement, Balance Sheet, and Cash flow Statement) from SEC.gov containing recent...
-
Write comments in your programs. Programs with no comments will receive PARTIAL credits. For each program, the following info should at least be included at the top of the C file: Author and Date...
-
Find the correct boilerplate Arduino code? . B.. C. const dataType variableName [] PROGMEM = {; dataType const PROGMEM variableName]] = {}; dataType PROGMEM const variableName [] = {}; const dataType...
-
What do we need to add in the empty box to complete this circuit? and why? be prices and concise with complete information a) 1A I 1V +24V S1 152 K1 K2 2 4 2 2 K1 3 11 1Y212
-
in a linear search algorithm, what is the worst - case scenario? 3 6 3 6 A . . When key is the last element in array B . . When key is not found in array C . . When key is the first element in array...
-
The output of the code at the end is given in the line below: 01234012 Complete the missing part in the following python code to have an output given in the line above (Do not use extra spaces) for x...
-
Which of these is a traffic exchange point in the routing hierarchy of the Internet that connects national service providers? Peer network Network access point Regional service provider Wireless...
-
Windell Hotels, Inc. claims that it did not have a contract with Jennifer because she was a minor at the time of her dealings with Jones and that it is therefore not responsible to Jones. The...
-
In Problems 1522, find the principal needed now to get each amount; that is, find the present value. To get $750 after 2 years at 2.5% compounded quarterly.
-
Last year, Miley decided to terminate the S corporation election of her solely owned corporation on October 17, 2018 (effective immediately), in preparation for taking it public. At the time of the...
-
You have been assigned to compute the income tax provision for Motown Memories Inc. (MM) as of December 31, 2019. The companys income statement for 2019 is provided below: MM prepared the following...
-
Chandra was the sole shareholder of Pet Emporium, which was originally formed as an S corporation. When Pet Emporium terminated its S election on August 31, 2018, Chandra had a stock basis and an...
Study smarter with the SolutionInn App