Answer to Question #323962 in Java | JSP | JSF for sysy

Question #323962

Create a program that will calculate a student's total payment fee after a scholarship has been applied. Scholarship.java will contain two methods: setGrade() and getScholarship(). The setGrade() will process the scholarship application, and will set new amount to be paid, while getScholarship() will only return the new amount after being called.

GPAs ranging from 1.76 to 5.00 will not be eligible for a scholarship and must pay the full tuition. GPAs ranging from 1.46 to 1.75 will receive a partial scholarship. GPAs ranging from 1.00 to 1.45 will receive a full scholarship. Out-of-range GPAs are invalid.

In the main class (SurnameScholarship.java), the user will be asked to enter his/her GPA, tuition fee, and miscellaneous fee.


1
Expert's answer
2022-04-05T13:18:19-0400
import java.util.Scanner;

public class SurnameScholarship {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);

        double midMark = in.nextDouble();
        double payT = in.nextDouble();
        double othP = in.nextDouble();

        Scholarship sc = new Scholarship();
        sc.setGrade(midMark, othP);

        if(0 == sc.getScholarship()){
            System.out.println("Tuition fees = " + payT);
        }

        System.out.println("scholarship = " + sc.getScholarship());
    }
}


public class Scholarship {
    private double scholarship;

    public void setGrade(double grade, double scholarship) {

        if(1.76 <= grade & grade <= 5){
            this.scholarship = 0;
        } else if(1.46 <= grade & grade <= 1.75){
            this.scholarship = scholarship/2;
        } else if(1 <= grade & grade <= 1.45){
            this.scholarship = scholarship;
        } else{

        }
    }

    public double getScholarship() {
        return scholarship;
    }
}

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS