Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA/UNIX Make a program that finds the weighted arithmetic mean for a user specified number of (number,weight) pairs as well as the simple arithmetic mean

JAVA/UNIX

Make a program that finds the weighted arithmetic mean for a user specified number of (number,weight) pairs as well as the simple arithmetic mean of the numbers specified:

ask the user to enter an integer number n for the pairs

prompt and read n pairs (integer number, real number for the weight) provided by the user

displays the weighted arithmetic mean of all the n pairs and the simple arithmetic mean of the n numbers

Be sure:

if n is specified to be 0, the program computes the correct values. Include a sample run for this input.

The program works for any n specified (do not hardcode the number of pairs)

Example 1:

Input file contains:

6

9

3.4

24

46.6

67

9.5

9

23.1

84

45

32

3.1

After running your program with the input redirected to the above input file, the redirected output file should contain the following sample run:

Enter number of pairs: 6

Enter number 1: 9

Enter weight 1: 3.4

Enter number 2: 24

Enter weight 2: 46.6

Enter number 3: 67

Enter weight 3: 9.5

Enter number 4: 9

Enter weight 4: 23.1

Enter number 5: 84

Enter weight 5: 45.

Enter number 6: 32

Enter weight 6: 3.1

Simple arithmetic mean of these 6 numbers is: 37.50

Weighted arithmetic mean of these 6 pairs is: 44.93

Example2:

Input file contains:

0

Output file should contain:

Enter number of pairs: 0

Simple arithmetic mean of these 0 numbers is: 0

Weighted arithmetic mean of these 0 pairs is: 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions