Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; public class Arithmetic { // main method begins execution of Java application public static void main( String[] args ) { // create a
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); } }
separate methods and method invocations (calling a method) in the main method
Note that average is now a double variable.
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.
should be done in java.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started