Computer Science, asked by ansafca2470, 7 months ago

write a program in java to input marks of student in physics, chemistry and maths calculate and display student total marks.

Answers

Answered by shivashanthamani
1

Answer:

Consider 3 variables like p, c, m which are integers.

Use Scanner class to get the input i.e marks from the console.

Then take another variable sum to store total marks.

Use this formula - sum = p + c + m;

Finally print the sum.

Note : p - physics, c - chemistry ,m - maths.

If u want to take range of the marks, then apply conditions like p, c, m >= 0 and <=

100

Source code :

import java.util.*;

class Marks{

public static void main (string args[])

{ int p, c, m, sum;

Scanner sc = new Scanner(System.in);

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

p = sc.nextInt();

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

c = sc.nextInt();

System.out.println(Enter maths marks");

m = sc.nextInt();

sum = p + c + m;

System.out.println("Total marks are : " + sum);

}

}

Explanation:

Similar questions