Bonus Score


Submit solution


Points:100 (partial)
Time limit:1.0s
Memory limit:32M
Author:

Tags
Conditionals
Difficulty
Easy

Write a program that applies bonus score to given score in the range [1…9] by the following rules:

  • If the score is between 1 and 3, the program multiplies it by 10.
  • If the score is between 4 and 6, the program multiplies it by 100.
  • If the score is between 7 and 9, the program multiplies it by 1000.
  • If the score is less than 0 or more than 9, the program prints "invalid score".

Input

  • The only input line will contain one integer number - the score

Output

  • Output the score with the applied bonus

Constraints

  • The score will always be a valid integer number

Sample tests

Input Output
2 20
4 400
9 9000
10 invalid score

Comments


  • 0
    mitko_respect
     commented on Oct. 3, 2019 edit 2

    let input = Number(gets());

    switch(input) {

    case(input >= 1 && input <= 3):
        print(input * 10);
        break;
    case(input >= 4 && input <= 6):
        print(input * 100);
        break;
    case(input >= 7 && input <= 9):
        print(input * 100);
        break;
    case(input < 0 || input > 9):
        print("invalid score");
        break;

    }

    Някой да помогне къде греша?


  • 0
    ritsu
     commented on Oct. 29, 2018

    Привет, малко помощ за тази задача? Въвеждам следния код в ИнтелиДжей:

    import java.util.Scanner;

    public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        if (x <= 0 || x > 9) {
            System.out.println("Invalid Score");
        }
        if (x >= 1 && x <= 3) {
            System.out.println(x * 10);
        }
        if (x >= 4 && x <= 6) {
            System.out.println(x * 100);
        }
        if (x >= 7 && x <= 9) {
            System.out.println(x * 1000);
        }
    }

    }

    и платформата ми го приема само до 2рия кейс. При това решение: import java.util.Scanner;

    public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
    
        if (x < 1 || x > 9) {
            System.out.println("Invalid Score");
        } else if (x < 4) {
            System.out.println(x * 10);
        } else if (x < 7); {
            System.out.println(x * 100);
        } else {
            System.out.println(x * 1000);
        }
    }

    }

    пък ми подчертава else-a с ерор 'else' without 'if'.

    Наистина не мога да си открия грешките.


  • 0
    plamen.hhh
     commented on Aug. 25, 2018

    Тая задача се решава по-лесно със switch case.


    • 0
      n.matev
       commented on Sept. 18, 2018

      Така е, със switch-case е по-бързо, но пък с if е по-кратък и подреден кода. Съответно 42 срещу 22 реда код.


  • 1
    nizlatinov
     commented on June 23, 2018

    Последното условие трябва да бъде :

    If the score is less than or equal to 0 or more than 9, the program prints "invalid score".