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

  Program to find maximum-minimum of sequence of values

Common task which should be done in loop is to find maximum and minimum of sequence of values. File Temps.java contains program which reads in sequence of hourly temperature readings over 24- hour period.

  Create a java gui application using netbeans

Create a Java GUI application using Netbeans that allows the user to enter the number of hours spent in each activity and then calculates the number of pounds lost.

  Prompt the user to enter a positive integer

Create a project called Daily8. Add a C source file to the project named daily8.c. Write a program that  will prompt the user to enter a positive integer.

  What way to test if string is containe within another string

So that's when this curious consultant started wondering... what is the fastest way to test and see if a string is contained within another string?

  Prepare executable program and a dictionary program

Prepare executable program and a dictionary Program.

  Write a program that displays a drawing popular hangman game

Write a program that displays a drawing for the popular hangman game, as shown in Figure 15.32(c). draws a sketch for the hangman game.

  Write a method to save a linked list to a text file

Write a method to save a Linked List to a text file called file.txt. It must save the Linked List to the file with each node on a different line.

  How are java source code files named

What is the purpose of the wait(), notify(), and notifyAll() methods? How are Java source code files named?

  Class named person with fields for holding a person''s name

Design a class named Person with fields for holding a person's name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class's fields.

  Write the constructor date which has 3 parameters

The Date.java class. Implement a public class Date that represents a date composed of a month , day, and a year. Declare month, day, and year as integers. Date has a constructor with 3 parameters and 4 methods. Write the constructor Date which has..

  Write a rap about classes that rivals the javadev group

Write a rap about classes that rivals the JavaDev group. Write just a few sentences and see if your classmates can add on.

  The performance of a wimax network appears to be lower

the performance of a wimax network appears to be lower expected and you suspect interference to be the cause. write a 2

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