Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Name the class ArithmeticTest , and the java file ArithmeticTest.java. Please note that average is now a double variable!!! You should have separate methods to

Name the class ArithmeticTest, and the java file ArithmeticTest.java.

Please note that average is now a double variable!!!

You should have separate methods to perform arithmetic operations of sum, average, product, max and min of three integer numbers. Five (5) methods are needed.

In the main method, prompt and accept user inputs for three integer numbers, and invoke (call) the above methods to display results.

Program top comments and programming styles

// This program calculate sum, average, product, min and max of three user input integer.

// program uses class Scanner import java.util.Scanner;

public class Arithmetic { // main method begins execution of Java application public static void main( String[] args ) { // create a Scanner to obtain input from the command window Scanner input = new Scanner( System.in ); //invite users to input three integers System.out.print( "Enter first integer: " ); // prompt; when execute, the program will pause for user input int number1 = input.nextInt(); // read first number from user

System.out.print( "Enter second integer: " ); // prompt; when execute, the program will pause for user input int number2 = input.nextInt(); // read second number from user System.out.print( "Enter third integer: " ); // prompt; when execute, the program will pause for user input int number3 = input.nextInt(); // read third number from user

int sum = number1 + number2 + number3; double average = (number1 + number2 + number3) / 3.0; int product = number1 * number2 * number3; int min = number1; int max = number1; if (number2 > max) max = number2; if (number2 < min) min = number2; if (number3 > max) max = number3; if (number3 < min) min = number3; System.out.printf( "Sum of %d, %d and %d is %d ", number1, number2, number3, sum); // display sum System.out.printf( "Average of %d, %d and %d is %d ", number1, number2, number3, average); // display sum System.out.printf( "Product of %d, %d and %d is %d ", number1, number2, number3, product); // display sum System.out.printf( "Max of %d, %d and %d is %d ", number1, number2, number3, max); System.out.printf( "Min of %d, %d and %d is %d ", number1, number2, number3, min); } // end method main } // end class Addition

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions