Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace SpeedInfo
- {
- class SpeedInfo
- {
- static void Main()
- {
- double speed = double.Parse(Console.ReadLine());
- string info = "";
- if (speed <= 10)
- {
- info = "slow";
- }
- else if (speed <= 50)
- {
- info = "average";
- }
- else if (speed <= 150)
- {
- info = "fast";
- }
- else if (speed <= 1000)
- {
- info = "ultra fast";
- }
- else if (speed > 1000)
- {
- info = "extremely fast";
- }
- Console.WriteLine(info);
- }
- }
- }
- Решение с тернарен оператор:
- using System;
- namespace SpeedInfo
- {
- class SpeedInfo
- {
- static void Main()
- {
- double speed = double.Parse(Console.ReadLine());
- string info = speed <= 10 ? "slow" :
- speed <= 50 ? "average" :
- speed <= 150 ? "fast" :
- speed <= 1000 ? "ultra fast" : "extremely fast";
- Console.WriteLine(info);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement