Как сделать цикличность? - C#
Формулировка задачи:
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp8
- {
- class Program
- {
- static void Main()
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(@"Выберите арифметическое действие:
- Умножение (1)
- Деление (2)
- Сложение (3)
- Вычитание (4)");
- string q = Console.ReadLine();
- double a, b;
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.WriteLine(' ');
- Console.WriteLine("Введите первое значение");
- Console.ForegroundColor = ConsoleColor.Blue;
- a = double.Parse(Console.ReadLine());
- Console.WriteLine("Введите второе значение");
- b = double.Parse(Console.ReadLine());
- Console.WriteLine(' ');
- if (q == "1")
- {
- Console.WriteLine("Результат умножения = {0}", a * b);
- }
- if (q == "2")
- {
- Console.WriteLine("Результат деления = {0}", a / b);
- }
- if (q == "3")
- {
- Console.WriteLine("Результат сложения = {0}", a + b);
- }
- if (q == "4")
- {
- Console.WriteLine("Результат вычитания = {0}", a - b);
- }
- Console.ReadKey();
- }
- }
- }
Решение задачи: «Как сделать цикличность?»
textual
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp8
- {
- class Program
- {
- static void Main()
- {
- Console.ForegroundColor = ConsoleColor.Red;
- while (true)
- {
- Console.WriteLine(@"Выберите арифметическое действие:
- Умножение (1)
- Деление (2)
- Сложение (3)
- Вычитание (4)
- Выход(0)");
- string q = Console.ReadLine();
- double a, b;
- Console.ForegroundColor = ConsoleColor.Blue;
- Console.WriteLine(' ');
- Console.WriteLine("Введите первое значение");
- Console.ForegroundColor = ConsoleColor.Blue;
- a = double.Parse(Console.ReadLine());
- Console.WriteLine("Введите второе значение");
- b = double.Parse(Console.ReadLine());
- Console.WriteLine(' ');
- if (q == "1")
- {
- Console.WriteLine("Результат умножения = {0}", a * b);
- }
- if (q == "2")
- {
- Console.WriteLine("Результат деления = {0}", a / b);
- }
- if (q == "3")
- {
- Console.WriteLine("Результат сложения = {0}", a + b);
- }
- if (q == "4")
- {
- Console.WriteLine("Результат вычитания = {0}", a - b);
- }
- if (q == "0") break;
- }
- Console.ReadKey();
- }
- }
- }
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д