Write a program that inputs marks in three subject print their sum and average.

 

public static void main(String[] args) {

Scanner cin = new Scanner(System.in);

int a,b,c,sum;

float avg;

System.out.println(“Enter subject 1 marks”);

a=cin.nextInt();

System.out.println(“Enter subject 2 marks”);

b=cin.nextInt();

System.out.println(“Enter subject 3  marks”);

c=cin.nextInt();

sum = a+b+c;

avg=sum/3;

System.out.println(“Sum is=”+sum);

System.out.println(“Average is=”+avg);

}

}

Output

Leave a Reply

Your email address will not be published. Required fields are marked *