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.
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;
}
}
Comments
Leave a comment