Computer Science, asked by anirudhachakra25, 11 months ago

4. In an examination, you have appeared for three subjects ie. Physics, Chemistry
and Biology. Write a program in Java to calculate the average mark obtained
and finally display the marks in rounded-off form.
Take Physics, Chemistry and Biology marks as inputs.​

Answers

Answered by rogan21
38

Answer:

import java.util.Scanner;

public class Average {

public static void main(String[] args) {

Float num1, num2, num3, avg;

Scanner sc = new Scanner(System.in);

System.out.println("Enter physics marks : ");

num1 = sc.nextFloat();

System.out.println("Enter chemistry marks : ");

num2 = sc.nextFloat() ;

System.out.println("Enter biology marks : ");

num3 = sc.nextFloat();

sc.close();

avg = (num1 + num2 + num3)/3;

int val =(int)avg;

System.out.println("Average of these subjects: "+val);

}

}

Answered by shirisha1981
7

Answer:import java.util.Scanner;

public class Average {

public static void main(String[] args) {

Float num1, num2, num3, avg;

Scanner sc = new Scanner(System.in);

System.out.println("Enter physics marks : ");

num1 = sc.nextFloat();

System.out.println("Enter chemistry marks : ");

num2 = sc.nextFloat() ;

System.out.println("Enter biology marks : ");

num3 = sc.nextFloat();

sc.close();

avg = (num1 + num2 + num3)/3;

int val =(int)avg;

System.out.println("Average of these subjects: "+val);

}

}

Read more on Brainly.in - https://brainly.in/question/11331927#readmore

Similar questions