Loading...
Loading...
Loading...
A class teacher enters each student's name and marks in three subjects. For each student print the total, the average and PASS or FAIL; a student passes only when every mark is at least 35.
Write a class Student with fields name, m1, m2, m3 and methods int total(), double average() and boolean passed().
name total average result, with the average printed with two digits after the decimal point.Example
Input
2 Asha 78 91 84 Ravi 40 30 90
Output
Asha 253 84.33 PASS Ravi 160 53.33 FAIL
Ravi scored 30 in one subject, so he fails even with a good total.
Try the problem first. Open one hint at a time.
average() can call total() on the same object instead of adding the marks again.
Divide by 3.0, not 3, so the average keeps its decimals.
A pass needs all three conditions joined with &&.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor