galinyotsev123

ProgBasics03Conditional-Statements-Y07Scholarship

Jan 11th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. import java.text.DecimalFormat;
  2. import java.util.Scanner;
  3.  
  4. public class Y07Scholarship {
  5. public static void main(String[] args) {
  6. Scanner input = new Scanner(System.in);
  7. double income = Double.parseDouble(input.nextLine());
  8. double averageGrade = Double.parseDouble(input.nextLine());
  9. double minSalary = Double.parseDouble(input.nextLine());
  10.  
  11. double socialScholarship = Math.floor(minSalary * 0.35);
  12. double excellenceScholarship = Math.floor(averageGrade * 25);
  13. double higherScholarship = 0.0;
  14. DecimalFormat df = new DecimalFormat("#.##");
  15. if (averageGrade <= 4.50) {
  16. System.out.print("You cannot get a scholarship!");
  17. } else if (averageGrade > 4.50 && averageGrade < 5.50) {
  18. if (income > minSalary) {
  19. System.out.print("You cannot get a scholarship!");
  20. } else {
  21. System.out.printf("You get a Social scholarship " + df.format(socialScholarship) + " BGN");
  22. }
  23. } else if (averageGrade >= 5.50) {
  24. if (income < minSalary) {
  25. higherScholarship = Math.max(socialScholarship, excellenceScholarship);
  26. if (higherScholarship == socialScholarship) {
  27. System.out.printf("You get a Social scholarship " + df.format(socialScholarship) + " BGN");
  28. } else if (higherScholarship == excellenceScholarship) {
  29. System.out.printf("You get a scholarship for excellent results " + df.format(excellenceScholarship) + " BGN");
  30. }
  31. } else {
  32. System.out.printf("You get a scholarship for excellent results " + df.format(excellenceScholarship) + " BGN");
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment