Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace mainSolution
- {
- class Program
- {
- public class MyException : Exception
- {
- public MyException(string messege) : base(message: messege + "\n\n\n Exception founded by Decibit\n\n\n") { }
- public MyException() : base()
- {
- }
- public void Messsage()
- {
- Console.WriteLine("\n\n\n\n\n\n Invalid number, please enter a number from 1 to 10 \n\n\n\n\n\n");
- }
- }
- static void Main(string[] args)
- {
- try
- {
- Console.WriteLine("Enter the number (1 - 10) - number of problem");
- int ProblemNumber = Int32.Parse(Console.ReadLine());
- switch (ProblemNumber)
- {
- case 1: { FirstSolve(); break; }
- case 2: { SecondSolve(); break; }
- case 3: { ThirdSolve(); break; }
- case 4: { FourthSolve(); break; }
- case 5: { FifthSolve(); break; }
- case 6: { SixthSolve(); break; }
- case 7: { SeventhSolve(); break; }
- case 8: { EighthSlove(); break; }
- case 9: { NinthSlove(); break; }
- case 10: { TenthSlove(); break; }
- default:
- throw new MyException("");
- }
- }
- catch (MyException ex)
- {
- //Console.WriteLine(ex);
- Console.WriteLine(ex.Message);
- return;
- //throw;
- }
- }
- static void FirstSolve()
- {
- Console.WriteLine("Enter A:");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine($"a + b = {0}", a + b);
- }
- static void SecondSolve()
- {
- Console.WriteLine("Enter A:");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine($"{a} + {b} = {b} + {a}");
- }
- static void ThirdSolve()
- {
- Console.WriteLine("Enter A:");
- int a = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- int b = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- int c = int.Parse(Console.ReadLine());
- Console.WriteLine($"{a + b + c}");
- }
- static void FourthSolve()
- {
- Console.WriteLine("Enter A:");
- double a = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- double b = double.Parse(Console.ReadLine());
- Console.WriteLine($"{a} * {b} = {a * b : .#}");
- }
- static void FifthSolve()
- {
- Console.WriteLine("Enter A:");
- double a = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- double b = double.Parse(Console.ReadLine());
- try
- {
- if (b == 0) throw new DivideByZeroException();
- else Console.WriteLine($"{a} / {b} = {a / b: .###}");
- }
- catch (DivideByZeroException error)
- {
- Console.WriteLine($"{error.Message} (founded by DeciBit)");
- //throw;
- }
- }
- static void SixthSolve()
- {
- Console.WriteLine("Enter A:");
- double a = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter B:");
- double b = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter C:");
- double c = double.Parse(Console.ReadLine());
- Console.WriteLine($"({a} + {b}) + {c} = {a} + ({b} + {c})");
- }
- static void SeventhSolve()
- {
- Console.WriteLine("Enter Denomination:");
- double a = double.Parse(Console.ReadLine());
- Console.WriteLine("Enter Number of Bills:");
- double b = double.Parse(Console.ReadLine());
- Console.WriteLine($"Amount of Money : {a * b:#.##} р");
- }
- static void EighthSlove()
- {
- Console.WriteLine("Enter Deposit amount:");
- decimal a = decimal.Parse(Console.ReadLine());
- Console.WriteLine("Enter Interest on deposit:");
- decimal b = decimal.Parse(Console.ReadLine());
- Console.WriteLine($"Accrue in a year: {a * (b / 100) : .###}");
- }
- static void NinthSlove()
- {
- Console.WriteLine("Enter Deposit amount:");
- decimal a = decimal.Parse(Console.ReadLine());
- Console.WriteLine("Enter Interest on deposit:");
- decimal b = decimal.Parse(Console.ReadLine());
- Console.WriteLine($"Invoice amount in a year : {a + a * (b / 100) : .##}");
- }
- static void TenthSlove()
- {
- Console.WriteLine("What's your name?:");
- string s = Console.ReadLine();
- Console.WriteLine("How old are you?:");
- int old = int.Parse(Console.ReadLine());
- Console.WriteLine($"{s}, you were born in {2009 - old}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement