Calculate the average of the values in the integer array

Assignment Help JAVA Programming
Reference no: EM131016336

Create, using NetBeans, a complete Java program called CalcWeightedAvg according to the following guidelines.

The program should use methods to carry out all computations. The method readIntValues should take no arguments, prompt the user to enter one line of between 5 and 10 space-separated integers with values between 0 and 100 (inclusive) and return an array of these integers.

The method getWeight should take no arguments, and it should prompt the user for a double with value greater than 0.0 but less than or equal to 1.0, and return as a double the value the user entered. The method calcWeightedAvg should return a double and take two parameters: an array of integers and a double called weight (with values greater than 0.0 but less than or equal to 1.0).

It should calculate the average of the values in the integer array, multiply that average by the weight, and return the result. For example, if calcWeightedAvg is invoked as calcWeightedAvg(intArray, weight) (with weight = 0.50) then it should calculate the average of all values in intArray, multiply that average by 0.50 and return the result to the main method which will then display that value to the user.

Example: integer input: 0 20 40 60 80 100 weight input: 0.50 calcWeightedAvg invoked as calcWeightedAvg(intArray, weight) returns 25.0. Thoughts: *) The method readIntValues will probably be the most challenging one to write, since the integer values you want will be embedded in the line of input, which is a string. I'll give some suggestions about how this might be done. *) Print some explanatory information with your result, such as, "With input values 0 20 40 60 80 100, and with a weight of 0.50, the weighted average of the all the values is 25.0."

Reference no: EM131016336

Questions Cloud

Discuss the persistent societal conflicts in society : In view of this statement discuss the persistent societal conflicts in society, which often result from reactions to social, economic and cultural differences in urban areas
Activity rate for product design activity cost pool : What is the activity rate for the Product Design activity cost pool? Product design activity cost pool $ per product
How does pr organisational role compromise : How does PR's organisational role compromise or facilitate a positive contribution to society
Predetermined overhead rates : What predetermined overhead rates would be used in the Machining and Assembly Departments, respectively?
Calculate the average of the values in the integer array : Calculate the average of the values in the integer array, multiply that average by the weight, and return the result - The method calcWeightedAvg should return a double and take two parameters
Do you see evidence of slow fahion : Do you see evidence of "Slow fahion" continuing since the publication of this artical 8 years a go? Support your opinion with concrete examples. Justify your position
What will be the ratio of the age of p and q after four year : The ratio between the present ages of P and Q is 6 : 7. If Q is 4 years old than P, what willbe the ratio of the ages of P and Q after 4 years?
Change in the status of chinese women : This is a two part assignment which is based on the topic of "the change in the status of Chinese women during the communist revolution
How many more people preferred wwcn than wanr : The graph represents the results of a survey in which 400 people were asked to identify the TV channel on which they preferred to watch the evening news. How many more people preferred WWCN than WANR?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd