Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MoreMethodExercises
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter the type of the input: ");
- string type = Console.ReadLine();
- if (type.Equals("int"))
- {
- int num = int.Parse(Console.ReadLine());
- intMethod(num);
- }
- else if (type.Equals("real"))
- {
- double num = double.Parse(Console.ReadLine());
- realMethod(num);
- }
- else if (type.Equals("string"))
- {
- string word = Console.ReadLine();
- stringMethod(word);
- }
- }
- static void intMethod(int number)
- {
- Console.WriteLine(number * 2);
- }
- static void realMethod(double number)
- {
- Console.WriteLine("{0:F2}",number*1.5);
- }
- static void stringMethod(string word)
- {
- Console.WriteLine("$" + word + "$");
- }
- }
- }
Add Comment
Please, Sign In to add comment