Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

java code write a program that, with given three integers from keyboard, determi

ID: 3861399 • Letter: J

Question

java code write a program that, with given three integers from keyboard, determine whether each integer is odd, even, select largest and smallest, and calculate the sum, average, and product. Then, you display the results on the screen. You will use Scanner class to make user input, and use if statement to determine largest, smallest number as well as even or odd number.

variables: Define your  variables and  data  type of  each  variable.    Include  Scanner and DecimalFormat class:  Import Scanner  classs and create Scanner object.
Import DecimalFormat class and  create   DecimalFormat   object Make use input rom keyboard: Input three integers  from   keyboard and save it to local variable
should be one line input. Calculate sum, average, product,and determine whether  each  number  is  odd  or even: Calculate  sum, average  and product  save it  to local  variable.
Determine odd  or even  and save it  to  local  variable. Decide largest  and   smallest  number: Select  the  largest  number among  three integers –use  if only statement only.
Select  the smallest number among three integers  –  use if only  statement only. Display the result  on the screen your result   should be formatt as follows:
Print whether each number  is odd or  integers use if only statement only.
Print  largest,  smallest,  sum,  average, and product of  three integers

Explanation / Answer

code:

import java.util.Scanner;
public class HelloWorld{
public static int max(int a,int b)
{
if (a>b)
return a;
else
return b;
}
public static int min(int a,int b)
{
if (a>b)
return b;
else
return a;
}
public static void main(String []args){
Scanner sc=new Scanner(System.in);

System.out.println("Enter number 1");
int no1=sc.nextInt();
System.out.println("Enter number 2");
int no2=sc.nextInt();
System.out.println("Enter number 3");
int no3=sc.nextInt();
int sum =no1+no2+no3;
float avg= (no1+no2+no3)/3;
int prod = no1*no2*no3;
int lar = max(max(no1,no2),no3);
int smal = min(min(no1,no2),no3);
if(no1%2==0)
System.out.println("number 1 is even");
else
System.out.println("number 1 is odd");
  
if(no2%2==0)
System.out.println("number 2 is even");
else
System.out.println("number 2 is odd");
  
if(no3%2==0)
System.out.println("number 3 is even");
else
System.out.println("number 3 is odd");
System.out.println("sum is: "+sum);
System.out.println("avg is: "+avg);
System.out.println("prod is: "+prod);
System.out.println("smallest is: "+smal);
System.out.println("largest is: "+lar);
}
}