Question: Write a program and draw a flowchat plese do not forget to draw flowchart in java to find the average of a set numbers using
Write a program and draw a flowchat plese do not forget to draw flowchart in java 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, the header of the method should be
public static void inputValue (int[ ] , Scanner)
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 findAvg (int[ ] ) public static double findAvg (double[ ] )
2 method named printResult that prints the inputted data and average , the header of the method should be
public static void printResult (int[ ] , double) public static void printResult (double[ ] , double)
Find the average of integer data set by invoking appropriate methods in main method, format to 2 decimal places
Enter a character: i Enter a number: 4 Enter 4 integers: 2 4 6 10 The average of 2 4 6 10 is 5.50
Find the average of real number data set by invoking appropriate methods in main method, format to 2 decimal places
Enter a character: R Enter a number: 3 Enter 3 real numbers: 3.66 5.795 7.1203 The average of 3.66 5.795 7.1203 is 5.53
If the inputted character is not valid, print an error message
Enter a character: t t is not the valid character.
/*
Proram: method overload
Write a program to find the average of a set numbers using method overloading.
The program first prompts the user to enter a character, if the character is 'I' or 'i', then invokes the methods to
process integer data set, if the character is 'R' or 'r',
then invokes the methods to process real number data set.
*/
import java.util.*;
public class Prog_MethodOverload_Avg{
//write 7 methods here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
