Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9. class Program
  10. {
  11. public static void Main(string[] args)
  12. {
  13.  
  14. char multiplication = 'B';
  15. char division = 'A';
  16. char addition = 'C';
  17. char subtraction = 'D';
  18.  
  19. while (true)
  20. {
  21. Console.WriteLine("Pick one of these four letters for the calculation.. A: Division, B: Multiplication, C:Additon, D: Subtraction");
  22. string choice = Console.ReadLine();
  23.  
  24. bool multichoice = (choice.Contains(multiplication));
  25. bool divchoice = (choice.Contains(division));
  26. bool addchoice = (choice.Contains(addition));
  27. bool subchoice = (choice.Contains(subtraction));
  28.  
  29. Console.WriteLine("What is your first number?");
  30. double first_number;
  31. Double.TryParse(Console.ReadLine(), out first_number);
  32.  
  33.  
  34. Console.WriteLine("What is your second number?");
  35. double second_number;
  36. Double.TryParse(Console.ReadLine(), out second_number);
  37.  
  38. if (multichoice == true)
  39. {
  40. Console.WriteLine("Your result is: " + Multiplication(first_number, second_number));
  41. Console.ReadLine();
  42. }
  43.  
  44. else if (divchoice == true)
  45. {
  46. Console.WriteLine("Your result is: " + Division(first_number, second_number));
  47. Console.ReadLine();
  48. }
  49.  
  50. else if (addchoice == true)
  51. {
  52. Console.WriteLine("Your result is: " + Addition(first_number, second_number));
  53. Console.ReadLine();
  54. }
  55.  
  56. else if (subchoice == true)
  57. {
  58. Console.WriteLine("Your result is: " + Subtraction(first_number, second_number));
  59. Console.ReadLine();
  60. }
  61.  
  62. else
  63. {
  64. Console.WriteLine("Please write in one capitalised letter that is listed!");
  65. }
  66. }
  67. }
  68. static double Multiplication(double first_number, double second_number)
  69. {
  70. return first_number * second_number;
  71. }
  72. static double Division(double first_number, double second_number)
  73. {
  74. return first_number / second_number;
  75. }
  76. static double Addition(double first_number, double second_number)
  77. {
  78. return first_number + second_number;
  79. }
  80. static double Subtraction(double first_number, double second_number)
  81. {
  82. return first_number - second_number;
  83. }
  84. }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement