Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class PlayWithIntDoubleString
- {
- static void Main()
- {
- Console.WriteLine("Please choose a type:\n1 --> int\n2 --> double\n3 --> string");
- int userInput = int.Parse(Console.ReadLine());
- switch (userInput)
- {
- case 1:
- {
- Console.WriteLine("Please enter an integer.");
- int userInt = int.Parse(Console.ReadLine());
- int increaseInt = userInt + 1;
- Console.WriteLine("New number:/n{0}", increaseInt);
- break;
- }
- case 2:
- {
- Console.WriteLine("Please enter a double.");
- double userDouble = double.Parse(Console.ReadLine());
- double increaseDouble = userDouble + 1.0;
- Console.WriteLine("New number:\n{0}", increaseDouble);
- break;
- }
- case 3:
- {
- Console.WriteLine("Please enter a string.");
- string userString = Console.ReadLine();
- string concatString = userString + "*";
- Console.WriteLine("New string:\n{0}", concatString);
- break;
- }
- default:
- {
- Console.WriteLine("Wrong input!");
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment