Knowee
Questions
Features
Study Tools

Arjun is working on a math project and needs a program to find the average (mean) of two types of numbers: whole numbers (integers) and numbers with decimal points (doubles). He wants to write a program but is having trouble with a concept called "constructor overloading." Arjun needs your help to write a program.Input format :The first line of input consists of an integer n, representing the number of elements in the arrays.The second line of input consists of n space-separated integers representing the elements of the intArray.The third line of input consists of n space-separated double-point numbers representing the elements of the doubleList.Output format :The output consists of two lines:The mean (average) of the integers in intArray, displayed with two decimal places.The mean (average) of the double-point numbers in doubleList, displayed with two decimal places.Refer to the sample output for the formatting specifications.Code constraints :1 ≤ n ≤ 101 ≤ int elements ≤ 10001.0 ≤ double elements ≤ 1000.0Sample test cases :Input 1 :510 20 30 40 501.5 2.5 3.5 4.5 5.5Output 1 :30.003.50

Question

Arjun is working on a math project and needs a program to find the average (mean) of two types of numbers: whole numbers (integers) and numbers with decimal points (doubles). He wants to write a program but is having trouble with a concept called "constructor overloading." Arjun needs your help to write a program.Input format :The first line of input consists of an integer n, representing the number of elements in the arrays.The second line of input consists of n space-separated integers representing the elements of the intArray.The third line of input consists of n space-separated double-point numbers representing the elements of the doubleList.Output format :The output consists of two lines:The mean (average) of the integers in intArray, displayed with two decimal places.The mean (average) of the double-point numbers in doubleList, displayed with two decimal places.Refer to the sample output for the formatting specifications.Code constraints :1 ≤ n ≤ 101 ≤ int elements ≤ 10001.0 ≤ double elements ≤ 1000.0Sample test cases :Input 1 :510 20 30 40 501.5 2.5 3.5 4.5 5.5Output 1 :30.003.50

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Sure, here is a simple Java program that uses constructor overloading to calculate the average of an array of integers and an array of doubles:

public class AverageCalculator {
    private double sum = 0;
    private int length;

    // Constructor for integer array
    public AverageCalculator(int[] array

Similar Questions

Initialize an array/list with five integers. Write a program to find the sumand average of these numbers

Problem StatementDevelop a program to demonstrate the concept of method overloading. Create an add() methods which adds two integers, two double type values and three integers.Input FormatFirst line input two integer values separated by spaceSecond line input two double values separated by spaceThird line input three integer values separated by spaceOutput FormatPrint sum of two integers in first linePrint sum of two doubles in second line.Print sum of three integers in last line.Sample Input2 30.67 1.984 9 18Sample OutputSum of integers: 5Sum of doubles: 2.65Sum of three integers: 31

Problem StatementWrite a program to find the average of N numbers. Print the average in 2 digit precision DO NOT USE ARRAYInput FormatFirst line consist of a single integer - 'N'Second line consist of N space separated integersOutput FormatDisplay the average of N numbersSample Input51 2 3 4 5Sample Output3.00

import java.util.Scanner; public class Test1 { public static void main(String[] args) {     Scanner input = new Scanner(System.in);     System.out.print("Enter three numbers: ");     float number1 = input.nextInt();     float number2 = input.nextInt();     float number3 = input.nextInt();     float number4 = input.nextInt();     // Compute average     double average = (number1 + number2 + number3 + number4) / 4;     // Display result     System.out.println(average);   } }  When a user enters 1   2   3  4 during the program execution what will be the exact output?  Group of answer choices2.02.53.0The program gives an error.

Single File Programming QuestionProblem StatementJamie is managing a school and is looking to find out the number of students in the class based on the sum of their scores and the average score.He wants to design a program that takes the average score and sum of scores as input and outputs the calculated number of students in the class using pointers.Input format :The first line of input consists of an integer value n, representing the sum of scores.The second line of input consists of a floating-point value f, representing the average score.Output format :The output displays the calculated number of students in the class.Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1 ≤ n ≤ 1051.0 ≤ f ≤ 100.0Sample test cases :Input 1 :187575.45Output 1 :24Input 2 :20010.25Output 2 :19Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.Marks : 10Negative Marks : 0WhitelistSet 1:*

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.