Comp274 Lab1

Comp274 Lab1

import java.util.Scanner; //Allows the use of Scanner utility.
public class firstlab {


public static void main(String[] args) {

//Variables
int num1;
int num2;
int num3;
int smallest;
int largest;


Scanner num = new Scanner(System.in); //Enables the Scanner.
System.out.print("Enter the 1st number: "); //Prompts the user to enter the first number.
num1 = num.nextInt(); //Saves first number as num1.
largest = num1; //Sets largest to num1.
smallest = num1; //Sets smallest to num1.

System.out.print("Enter the 2nd number: "); //Prompts the user to enter the second number.
num2 = num.nextInt(); //Saves second number as num2.
if (num2 > num1) //Verifies num2 against num1.
largest = num2; //If num2 is larger than num1 it becomes largest.
else
smallest = num2; //If not num2 is smallest.
System.out.print("Enter the 3rd number: "); //Prompts the user to enter the third number
num3 = num.nextInt(); //Saves third number as num3.

if (num3 > num2 && num3 > num1) //Verifies num3 against num1 and num2.
largest = num3; //If num3 is larger than both it becomes largest.
if (num3 < num2 && num3 < num1) //Verifies num3 against num1 and num2.
smallest = num3; //If num3 is smaller than both it becomes smallest.
System.out.println(); //Spacing.

System.out.println("Sum = " + (num1 + num2 + num3)); //Sum of all three integers.

System.out.printf("Average = %.2f\n", (num1 + num2 + num3) / 3.0); //Average of all three integers, with two digits after decimal.

System.out.println("Product = " + (num1) * (num2) * (num3)); //Product of all three integers....