Part1) Simple Calculator Programusing Scanners Write a Java application that inp
ID: 3613612 • Letter: P
Question
Part1) Simple Calculator Programusing ScannersWrite a Java application that inputsthree integers from the user and displays the sum, average,product, smallest, and largest of the numbers. Use a Scanner objectto get the input from the user. Use System.out to output theresults. The average should be a floating point result, and shouldbe displayed with 2 digits after the decimal point.
Part2) Simple Calculator Program usingJOptionPanes
Student will modify the Java application fromprogram 1. The new version of the program will use JOptionPanes forinput and output. Use String.format("%.2f", doubleVariable) tocreate a string representation with 2 digits following the decimalpoint.
This is what I have for part 1 so far:
I haven started on part2 yet. Can someone please help me getthis program going? In part1 the sum, product and averagevalues has been executed but I can't seen to figure out the codesto get the smallest and largest value. And also I need helpto determine how to write a program for the second part(part2). Thanks
import java.util.*; //This enable the date andtime
import java.io.*; //This enable input andoutput
import java.math.*;
public class scanner {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated methodstub
int nu1 = 0;
int nu2 = 0;
int nu3 = 0;
int value;;
int smallest =Integer.MIN_VALUE;
int largest =Integer.MAX_VALUE;
/*This code command enablethe input interface for the user to
input in a value.*/
//The first integer value
Scanner num10 = newScanner(System.in);
System.out.print("User pleaseENTER the first integer value: ");
nu1 =num10.nextInt(); //The input: user enter in.
System.out.println("You haveenter: " + nu1);
value = nu1;
//The second integervalue
Scanner num11 = newScanner(System.in);
System.out.print("User pleaseENTER the second integer value: ");
nu2 = num11.nextInt(); //Theinput: user enter in.
System.out.println("You haveenter: " + nu2);
value = nu2;
//The third integer value
Scanner num12 = newScanner(System.in);
System.out.print("User pleaseENTER the third integer value: ");
nu3 = num12.nextInt(); //The input: user enter in.
System.out.println("You haveenter: " + nu3 );
value = nu3;
System.out.println(); //Blink line
System.out.println("_________________________________________________");
//The SUM of all three numberof which the user input.
System.out.println("Sum = " +(nu1 + nu2 + nu3));
//The product of the threeinput
System.out.println("Product =" + (nu1) * (nu2) * (nu3));
//The average value
System.out.println("Average=" + (nu1 + nu2 + nu3) / 3);
//Smallest value
if(value < smallest);{
System.out.println("TheSmallest is: " + smallest);
}
//Largest value
if(value > largest);{
System.out.println("TheLargest is: " + largest);
}
}
}
Explanation / Answer
p