write a program to input the marks of 3 subjects and the subject name display the subject name and average mark of students
Answers
import java.util.*;
public class Avg
{
public static void main (String args [])
{
Scanner sc=new Scanner (System.in);
System.out.println("Please Enter The Name Of The First Subject");
char Sub1 = sc.next().charAt(0);
System.out.println("Please Enter The Marks");
double a = sc.nextDouble();
System.out.println("Please Enter The Name Of The Second Subject");
char Sub2 = sc.next().charAt(0);
System.out.println("Please Enter The Marks");
double b = sc.nextDouble();
System.out.println("Please Enter The Name Of The Third Subject");
char Sub3 = sc.next().charAt(0);
System.out.println("Please Enter The Marks");
double c = sc.nextDouble();
double avg = (a+b+c)/3;
System.out.println("Average Marks = "+avg);
sc.close();
}
}