coasterka

#5PlayWithIntDoubleString

Mar 28th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2.  
  3. class PlayWithIntDoubleString
  4. {
  5.     static void Main()
  6.     {
  7.         Console.WriteLine("Please choose a type:\n1 --> int\n2 --> double\n3 --> string");
  8.         int userInput = int.Parse(Console.ReadLine());
  9.         switch (userInput)
  10.         {
  11.             case 1:
  12.                 {
  13.                     Console.WriteLine("Please enter an integer.");
  14.                     int userInt = int.Parse(Console.ReadLine());
  15.                     int increaseInt = userInt + 1;
  16.                     Console.WriteLine("New number:/n{0}", increaseInt);
  17.                     break;
  18.                 }
  19.             case 2:
  20.                 {
  21.                     Console.WriteLine("Please enter a double.");
  22.                     double userDouble = double.Parse(Console.ReadLine());
  23.                     double increaseDouble = userDouble + 1.0;
  24.                     Console.WriteLine("New number:\n{0}", increaseDouble);
  25.                     break;
  26.                 }
  27.             case 3:
  28.                 {
  29.                     Console.WriteLine("Please enter a string.");
  30.                     string userString = Console.ReadLine();
  31.                     string concatString = userString + "*";
  32.                     Console.WriteLine("New string:\n{0}", concatString);
  33.                     break;
  34.                 }
  35.             default:
  36.                 {
  37.                     Console.WriteLine("Wrong input!");
  38.                     break;
  39.                 }
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment