Question 2.11: Write a Java program that takes three numbers as input to calculate and print the average of the numbers.
Solution:
package com.company;
import java.util.Scanner;
public class Lab2problem11 {
public static void main(String[] args)
{
Scanner Obj =new Scanner(System.in);
System.out.println("enter the first value");
int a =Obj.nextInt();
System.out.println("enter the first value");
int b =Obj.nextInt();
System.out.println("enter the first value");
int c =Obj.nextInt();
int sum = a+b+c;
double ave =(double) sum/3;
System.out.println("the result is: " + ave);
}
}