IDNLearn.com offers a collaborative platform for sharing and gaining knowledge. Our community provides timely and precise responses to help you understand and solve any issue you face.
Sagot :
The program that prompts the user for three integers and displays their average as a floating point is given below:
The Code:
import java.util.Scanner;
public class ArithmeticSmallestLargest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int num1;
int num2;
int num3;
int sum;
int average;
int product;
int largest;
int smallest;
System.out.print("Enter First Integer: ");
num1 = input.nextInt();
System.out.print("Enter Second Integer: ");
num2 = input.nextInt();
System.out.print("Enter Third Integer: ");
num3 = input.nextInt();
sum = num1 + num2 + num3;
average = sum / 3;
product = num1 * num2 * num3;
largest = num1;
smallest = num1;
if(num2 > largest)
largest = num2;
if(num3 > largest)
largest = num3;
if(num2 < smallest)
smallest = num2;
if (num3 < smallest)
smallest = num3;
System.out.println("The sum is " + sum);
System.out.println("The average is " + average);
System.out.println("The product is " + product);
System.out.println("Largest of three integers is " + largest + " and the smallest is "+ smallest + ".");
}
}
Read more about java programming here:
https://brainly.com/question/18554491
#SPJ1
We greatly appreciate every question and answer you provide. Keep engaging and finding the best solutions. This community is the perfect place to learn and grow together. Thank you for choosing IDNLearn.com for your queries. We’re committed to providing accurate answers, so visit us again soon.