/**
* Write a program to get a student marks.
* The marks consist Lab1,Test1 and PBT1.
* If the average of marks is below than 40,
* output "Student cannot sit final exam" will display.
* You must apply constructor in your program.
*/
import java.util.Scanner;
public class StudentMarks {
private double avg;
// constructor
public StudentMarks(double lab1, double test1, double pbt1) {
avg = (lab1 + test1 + pbt1) / 3.0;
}
public void checkForFinalExam() {
if (avg < 40.0)
System.out.println("Student cannot sit final exam");
else
System.out.println("Student can sit final exam");
}
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Entare mark for Lab1:");
double lab1 = input.nextDouble();
System.out.print("Entare mark for Test1:");
double test1 = input.nextDouble();
System.out.print("Entare mark for PBT1:");
double pbt1 = input.nextDouble();
StudentMarks studentMarks = new StudentMarks(lab1, test1, pbt1);
studentMarks.checkForFinalExam();
}
}
Comments
Thank you so much :D if you have more please upload, i would really appreciate it.
Leave a comment