Assignment First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "AverageWithMethods" (without the quotation marks) according to the following guidelines. The program prompts the user for five to ten numbers, all on one line, and separated by spaces.  Then the user calculates the average of those numbers, and displays the numbers and their average to the user. The program uses methods to: Get the numbers entered by the user Calculate the average of the numbers entered by the user Print the results with the whole number, a decimal, and two decimal positions The first method should take no arguments and return a String of numbers separated by spaces.  [CASE 2] The second method should take a String as its only argument and return a double (the average).  [CASE 4]   The third method should take a String and a double as arguments but have no return value.          [CASE 3] For example, if the user input is...  20 40 60 80 100 ...the program should give as output...  The average of the numbers 20 40 60 80 100 is 60.00. BE SURE TO INCLUDE THE OUTPUT FROM MULTIPLE PROGRAM RUNS AS A COMMENT BLOCK AT THE BOTTOM OF YOUR SOURCE CODE FILE. Thoughts Refer to Horstmann chapter 2 for details on formatting output values.

Question

Assignment

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).

Then create a new Java application called "AverageWithMethods" (without the quotation marks) according to the following guidelines.

The program prompts the user for five to ten numbers, all on one line, and separated by spaces.  Then the user calculates the average of those numbers, and displays the numbers and their average to the user.

The program uses methods to:

  1. Get the numbers entered by the user
  2. Calculate the average of the numbers entered by the user
  3. Print the results with the whole number, a decimal, and two decimal positions

The first method should take no arguments and return a String of numbers separated by spaces.  [CASE 2]

The second method should take a String as its only argument and return a double (the average).  [CASE 4]  

The third method should take a String and a double as arguments but have no return value.          [CASE 3]

For example, if the user input is...  20 40 60 80 100

...the program should give as output...  The average of the numbers 20 40 60 80 100 is 60.00.

BE SURE TO INCLUDE THE OUTPUT FROM MULTIPLE PROGRAM RUNS AS A COMMENT BLOCK AT THE BOTTOM OF YOUR SOURCE CODE FILE.

Thoughts

Refer to Horstmann chapter 2 for details on formatting output values.

 

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Discuss the approaches used to categorize access control methodologies. Discuss the types of control...

A: Answer:Access control:Access control is a security technique that controls the admission of workers ...

Q: Design a reasonably efficient algorithm for solving each of the following problems and determine its...

A: Algorithm to find who failed to pay telephone billFor finding who failed to pay telephone bill, firs...

Q: Problem 1 consists of multiple parts. You should finish one part and ensure that it works before mov...

A: Hello. Since your question has multiple sub-parts, we will solve first three sub-parts for you. If y...

Q: CLASS OF 2019 Welcome MySAIL Oakland Un X Th Course: CSI-1420-43702.201940 X https://moodle.oakland....

A: Create a main method in the C program and read input from the user. And subtract the second time, wh...

Q: Using DeMorgan's Law, write an expression for the complement of F ifF(x,y,z) = xz' (xy + xz)+ xy'(wz...

A: DeMorgan’s law:The theorems of DeMorgan are basically two sets of rules or laws developed for AND, O...

Q: write code in c++ to calculate f(0.006), wheref(x) = e−x − cos xln(x + 1)correctly to ten decimal pl...

A: Create a C++ program and include all required modules.Define a macro "e" with value 2.71828.Create a...

Q: Create a method multiply(), that receives the 2D array you created in 2. as aninput, multiplies all ...

A: Click to see the answer

Q: Using the network access control for a diagram drawn as a model, investigate the network access cont...

A: Network Access Control (NAC):Network Access Control (NAC) is one of the most important approaches fo...

Q: How did Cisco systems solve physical security problems?

A: Cisco is a US-based technology corporation best known for its networking services. As a company that...

Q: Consider the following code. What will be printed out by the code?

A: Implementing the given program code in a class to get the output and modifying some output statement...

Q: In Lab 2, you created a menu for a simple calculator program. In Lab 6, you added some functionality...

A: Program Algorithm-STARTStep1 Import essential headers.Step2 Define main functionStep3 Print “Hello u...

Q: Using a conditional expression, write a statement that increments numUsers if updateDirection is 1, ...

A: To create a conditional expression, by adding some code statements to the given program code. So, th...

Q: Write a program that generates a two-column table showing Fahrenheit temperatures from -40F to 120F ...

A: Java program://Create a class name "temperature"public class temperature{     //Definition for main ...

Q: Find the truth table that describes the following circuit.

A: The diagram shown below is taken from the given question- 

Q: Python 3.7.4 (Introductory Level) You want to know your grade in Computer Science: Write a program t...

A: Program:total_grades = 0n = 0average=0print("Enter the grade:")grades = input()while grades != "stop...

Q: Databse SQL Queries. Need to write the SQL code for pulling the total cost of our inventory. We have...

A: A SQL query is to be written that will give the total cost of inventory. Two tables are given named ...

Q: Twin primes are two primes that differ by 2 (e.g., 3 and 5, 101 and 103). Write a ++ program that ou...

A: Program AlgorithmDeclare the required variables and an array of 1000 elements in main().Then use a f...

Q: (check all that apply) Which of the following is true about constraint names?A) it can be used for D...

A: A) it can be used for DBA to identify a constraint easily:Yes. Constraints are the rules that are ap...

Q: Create a new file (in Dev C++)  In Lab 2, you created a menu for a simple calculator program. In Lab...

A: Program AlgorithmDeclare the required variables and write a welcome message before starting the menu...

Q: Write down two approaches to reduce re-work cost. Inyour opinion how incremental delivery supports b...

A: The two approaches that are used to reduce re-work cost are as follows:Change toleranceChange avoida...

Q: Many documents use a specific format for a person's name. Write a program whose input is: firstName ...

A: This program can be done in a very easy way. Programming instruction: First, take the input from the...

Q: How to use if else statement

A: If-else statement is used when a particular block of code is to be executed when a certain condition...

Q: Write a program that asks for the name of an input file. Then, read all the numbers in the file, and...

A: Create a PYTHON3 file in which import io module and validate file in program.Print sum, number of el...

Q: Write the pseudocode  and Flowchart for a program that simulates the Magic eight ball game.

A: Pseudocode:Pseudocode is a detailed description of the algorithm of a program that is easier to read...

Q: Question 9: Consider the following: Class Course { protected: long CRN public: Course( long c ); }; ...

A: Paste all the code module after appropriate commented area.For example://write the Default construct...

Q: Write a query to display the book number, title, and cost for all books in the “Database” subject so...

A: The name of the table is the subject.Attributes of the table are book_number, book_title, book_costC...

Q: 8. Write a C++ program to find the sum of all odd integers from 1 to 99, and the sum of their cubes.

A: To solve this question following variables and loop should be required:Variables: total, num, and cu...

Q: Problem 3 Guessing game: For this program, have the user guess a number from 1-5. Next, generate a r...

A: Program instructions:Create a form with two fields and one submit button.User enters the number in a...

Q: Question 3

A: Writing the program code in java as in the given question no programming language is specified.This ...

Q: 1. (5.8 in 8e) Show the value of x after each of the following statements is performed: a) x fabs(7....

A: Since there are multiple questions and you have not specified which question is to be answered, we a...

Q: Odd man out: . Topological sort Algorithm DFS Algorithm Binary search Algorithm BFS Algorithm Prim's...

A: Answer:Binary Search AlgorithmExplanation:Topological sort Algorithm, DFS algorithm, BFS algorithm a...

Q: Arrays Write a for loop to print all elements in courseGrades, following each element with a space (...

A: Programming instructions: First, initialize the variable which takes the size of the array and an ar...

Q: PLEASE EXPLAIN ALL STEPS: simplify the boolean equations: xz + (xy + ~z) ~xyz + yz + x~y

A: 1)xz + (xy + ~z)For simplifying the Boolean expression, use Karnaugh Map and follow the below steps-...

Q: I am having trouble writing a python program that opens a file that contains baby names. One file fo...

A: To run this code, make all the files Boys.txt, Girls.txt and .py files in same folder.input() is use...

Q: What was Networking?

A: Networking:Networking, also known as computer networking, is the practice of transporting and exchan...

Q: Make this code more efficient   numb = int(input("What is your favourite number? ")) name = str(inpu...

A: To make this code more efficient do not use NOT and AND operation instead of this use nested if to m...

Q: Write a program TwoSmallest.java that takes a set of double command-line arguments and prints the sm...

A: Create a class and main method and in the main method declare all required variables to find the fir...

Q: Find the truth table that describes the following circuit:

A: The gates involved in the given circuits are:AND gate between Y and X.XNOR gate between Y and ~Z whi...

Q: This program is written in pseudocode."Design a program that generates a 7-ddigit lottery number. Th...

A: This pseudocode explains how to create a 7-digit lottery number. These 7 digits are randomly generat...

Q: I need help tackling this program:     Write a C++ console application that allows your user to ente...

A: For solving this problem following variables and data type are used to execute this file :1.Variable...

Q: In the table Enrollments (studentID, courseNo, sectionNo, grade, status), which of the followingfunc...

A: Functional dependencyA functional dependency is a relationship between two attributes mainly between...

Q: Security challenges of social networking sites

A: Security challenges of Social Network WebsitesSocial EngineeringIt involves techniques used by hacke...

Q: How would I go about writing this program?

A: Create a class and get int type data from a user, to print the number of lines on console.Use three ...

Q: PLEASE EXPLAIN ALL STEPS  In the following code, determine the values of the symbols this, that, and...

A: Before explaining the difference first user must know about the Assembly language.Assembly language:...

Q: Python 3.7.4 Write a statement that associates s with the empty set.

A: Set:A set is a list of unranked data items, in python data items can be added or removed in a set.Em...

Q: Describe some factors that increase computer efficiency. For example, increasing the number of CPU p...

A: A computer’s speed and performance are based on how good the hardware and software are working toget...

Q: Hi I am coding for java where I have to have 20 fibonacci numbers printed out 5 in a row. Then I nee...

A: In the given code, the statement “if(count==5)” is never gets “true” because , after printing each F...

Q: What issues and problems are raised by the use ofunintegrated information systems?

A: Loss and failures associated with computers are major computer issues, leading to unnecessarily high...

Q: 2. You are again working for the census bureau and they need some statistics regarding the distribut...

A: Create a PYTHON3 program, and import all required modules for the given problem, import the "statist...

Q: How would you modify the dynamic programming algorithm for the coin collecting problem if some cells...

A: Coin collecting problemIn a n-m board, several coins are placed in such a way no more than one coin ...