Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

Using Java Write a program to find the average of a set numbers using overload methods. The program first prompts the user to enter a

Using Java

Write a program to find the average of a set numbers using overload methods.

The program first prompts the user to enter a character; if the character is 'I' or 'i', then invokes the appropriate methods to process integer data set; if the character is 'R' or 'r', then invokes the appropriate methods to process real number data set; if the inputted character is not valid, print an error message.

The program MUST have the following six methods, in additional to the main method: 2 methods named inputValue that prompts the user to input N integers or N real numbers, 2 method named findAvg that returns the average of the data, 2 method named printResult that prints the inputted data and average.

Also use the math method to format into two decimal places.

image text in transcribed

Write a program to find the average of a set numbers using overload methods. The program first prompts the user to enter a character,the character is ,r or Y, then invokes the appropriate methods to process integer data set if the character is R or, then invokes the appropriate methods to process real number data set, if the inputted character is not valid, print an error message The program MUST have the following six methods, in additional to the main method (5 points): 2 methods named inputvalue that promots the user to input N integers cr N real numbers, the header of the methcd should be public static void inputvalue (intScanner) public static void inputValue (double[ ,Scanner) 2 method named findAvg that returns the average of the data, the header of the method should be public static double findAv (int public static double findAv (doublel ) 2 method named printResult that prints the inputted data and average, the header of the methcd should be public atatic void printRcault inc double) public static void printReault (doublel, double) Find the average of integer data set by invoking appropriate methods in main method, format to 2 decimal places (2 points) Enter a character:1 Enter thc nurnber In the data et : Enter 4 Integer: 2 6 10 The average ot 246 10 13 5.50 Find the average of real number data set by inwoking apprcpriate methods in main method, format to 2 decimal places (2 points) Enter a character: R Enter thc number in the data et: 3 Enter 3 real numbers: 3.66 5.795 7.1203 The average of 3.66 5.795 7.120 1 5.53 If the inputted character is not valid, print an error message (1 points) Enter a character: t t is not the valid character

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_2

Step: 3

blur-text-image_3

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

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students explore these related Databases questions