Answer to Question #94348 in Java | JSP | JSF for Nur Hanisah Dhamirah Binti Rostam

Question #94348
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.
1
Expert's answer
2019-09-13T05:51:09-0400
/**
 * 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();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Asri
05.11.20, 03:36

Thank you so much :D if you have more please upload, i would really appreciate it.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS