Advertisement
Teodor92

Bonuses

Oct 30th, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. /* Write a program that applies bonus scores to given scores in the range [1..9].
  2.  * The program reads a digit as an input. If the digit is between 1 and 3, the
  3.  * program multiplies it by 10; if it is between 4 and 6, multiplies it by 100;
  4.  * if it is between 7 and 9, multiplies it by 1000. If it is zero or if the value is not a digit,
  5.  * the program must report an error.
  6.  *   Use a switch statement and at the end print the calculated new value in the console.
  7.  */
  8.  
  9. using System;
  10.  
  11. class BonusScore
  12. {
  13.     static void Main()
  14.     {
  15.         int score = int.Parse(Console.ReadLine());
  16.         switch (score)
  17.         {
  18.             case 1:
  19.             case 2:
  20.             case 3:
  21.                 Console.WriteLine(score*10);
  22.         break;
  23.             case 4:
  24.             case 5:
  25.             case 6:
  26.                 Console.WriteLine(score * 100);
  27.         break;
  28.             case 7:
  29.             case 8:
  30.             case 9:
  31.                 Console.WriteLine(score * 1000);
  32.         break;
  33.             default: Console.WriteLine("Error!"); ;
  34.         break;
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement