Advertisement
GabrielHr00

Oscars

Nov 20th, 2022
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. package S4_ForLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Oscars {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. String actorName = scanner.nextLine();
  9. double startingPoints = Double.parseDouble(scanner.nextLine());
  10. int juryCount = Integer.parseInt(scanner.nextLine());
  11.  
  12. for (int i = 1; i <= juryCount; i++) {
  13. // read info about jury
  14. String graderName = scanner.nextLine();
  15. double pointFromGrader = Double.parseDouble(scanner.nextLine());
  16.  
  17. // calc grade for actor
  18. double gradeForActor = graderName.length() * pointFromGrader / 2;
  19.  
  20. // add points to starting points
  21. // startingPoints = startingPoints + gradeForActor;
  22. startingPoints += gradeForActor;
  23.  
  24. if(startingPoints > 1250.5) {
  25. System.out.printf("Congratulations, %s got a nominee for leading role with %.1f!", actorName, startingPoints);
  26. break;
  27. }
  28. }
  29.  
  30.  
  31. // check if not enough money
  32. if(startingPoints <= 1250.5) {
  33. double diff = 1250.5 - startingPoints;
  34. System.out.printf("Sorry, %s you need %.1f more!", actorName, diff);
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement