borkins

06. Bonus Score

Mar 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. /*
  2.  * Simple Conditions
  3.  */
  4. import java.util.Scanner;
  5.  
  6. public class _06_BonusScore
  7. {
  8.     public static void main(String[] args)
  9.     {
  10.         Scanner console = new Scanner(System.in);
  11.  
  12.         int score = Integer.parseInt(console.nextLine());
  13.         double bonus; // Declaring the 'bonus' variable.
  14.        
  15.         // If true: (score is between 'Integer.MIN_VALUE' and 100) let bonus = 5.
  16.         // If false: skip and continue
  17.         if (score <= 100) {
  18.             bonus = 5;
  19.         }
  20.         // If true: (score is between 101 and 999) evaluate the expr.
  21.         // If false: skip and continue
  22.         else if (score < 1000) {
  23.             bonus = score * 20 / 100d;
  24.         }
  25.         // (score is between 1000 and 'Integer.MAX_VALUE') evaluate the expr.      
  26.         else {
  27.             bonus = score * 10 / 100d;
  28.         }
  29.  
  30.         // If score is an even number, add 1 to 'bonus', else check next condition
  31.         if (score % 2 == 0) {
  32.             bonus += 1;
  33.         }
  34.         // If score's rightmost digit is 5, then add 2 to 'bonus', else skip and continue.
  35.         else if (score % 10 == 5) {
  36.             bonus += 2;
  37.         }
  38.  
  39.         System.out.println(bonus);
  40.         System.out.println(score + bonus);
  41.     }
  42. }
Add Comment
Please, Sign In to add comment