Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Simple Conditions
- */
- import java.util.Scanner;
- public class _06_BonusScore
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int score = Integer.parseInt(console.nextLine());
- double bonus; // Declaring the 'bonus' variable.
- // If true: (score is between 'Integer.MIN_VALUE' and 100) let bonus = 5.
- // If false: skip and continue
- if (score <= 100) {
- bonus = 5;
- }
- // If true: (score is between 101 and 999) evaluate the expr.
- // If false: skip and continue
- else if (score < 1000) {
- bonus = score * 20 / 100d;
- }
- // (score is between 1000 and 'Integer.MAX_VALUE') evaluate the expr.
- else {
- bonus = score * 10 / 100d;
- }
- // If score is an even number, add 1 to 'bonus', else check next condition
- if (score % 2 == 0) {
- bonus += 1;
- }
- // If score's rightmost digit is 5, then add 2 to 'bonus', else skip and continue.
- else if (score % 10 == 5) {
- bonus += 2;
- }
- System.out.println(bonus);
- System.out.println(score + bonus);
- }
- }
Add Comment
Please, Sign In to add comment