Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class Y07Scholarship {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- double income = Double.parseDouble(input.nextLine());
- double averageGrade = Double.parseDouble(input.nextLine());
- double minSalary = Double.parseDouble(input.nextLine());
- double socialScholarship = Math.floor(minSalary * 0.35);
- double excellenceScholarship = Math.floor(averageGrade * 25);
- double higherScholarship = 0.0;
- DecimalFormat df = new DecimalFormat("#.##");
- if (averageGrade <= 4.50) {
- System.out.print("You cannot get a scholarship!");
- } else if (averageGrade > 4.50 && averageGrade < 5.50) {
- if (income > minSalary) {
- System.out.print("You cannot get a scholarship!");
- } else {
- System.out.printf("You get a Social scholarship " + df.format(socialScholarship) + " BGN");
- }
- } else if (averageGrade >= 5.50) {
- if (income < minSalary) {
- higherScholarship = Math.max(socialScholarship, excellenceScholarship);
- if (higherScholarship == socialScholarship) {
- System.out.printf("You get a Social scholarship " + df.format(socialScholarship) + " BGN");
- } else if (higherScholarship == excellenceScholarship) {
- System.out.printf("You get a scholarship for excellent results " + df.format(excellenceScholarship) + " BGN");
- }
- } else {
- System.out.printf("You get a scholarship for excellent results " + df.format(excellenceScholarship) + " BGN");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment