Advertisement
VyaraG

BonusScore

Nov 29th, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2.  
  3. //Write a program that applies bonus score to given score in the range [1…9] by the following rules:
  4. //•   If the score is between 1 and 3, the program multiplies it by 10.
  5. //•   If the score is between 4 and 6, the program multiplies it by 100.
  6. //•   If the score is between 7 and 9, the program multiplies it by 1000.
  7. //•   If the score is 0 or more than 9, the program prints “invalid score”.
  8.  
  9. class BonusScore
  10. {
  11.     static void Main()
  12.     {
  13.         Console.Write("Enter a number from 1 to 9: ");
  14.         int n = int.Parse(Console.ReadLine());
  15.         if (n>=1 && n<=9)
  16.         {
  17.             if (n>=1 && n<=3)
  18.             {
  19.                 Console.WriteLine(n*10);
  20.             }
  21.             else if (n>=4 && n<=6)
  22.             {
  23.                 Console.WriteLine(n*100);
  24.             }
  25.             else if (n>=7 && n<=9)
  26.             {
  27.                 Console.WriteLine(n*1000);
  28.             }
  29.         }
  30.         else
  31.             Console.WriteLine("invalid score");
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement