VelizarAvramov

02. Choose a Drink 2.0

Nov 5th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Demo
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //Write a program, which receives a profession (as a string) and chooses the perfect drink for the person.Your program
  10.             //needs to get smarter. Now you will receive on the second line the quantities of the drink and you have to print the
  11.             //calculated the price.
  12.             string profession = Console.ReadLine();
  13.             int quantity = int.Parse(Console.ReadLine());
  14.  
  15.             double price = 0;
  16.             double water = 0.70;
  17.             double coffee = 1.00;
  18.             double beer = 1.70;
  19.             double tea = 1.20;
  20.  
  21.             if (profession == "Athlete")
  22.             {
  23.                 price = quantity * water;
  24.             }
  25.             else if (profession == "Businessman" || profession == "Businesswoman")
  26.             {
  27.                 price = quantity * coffee;
  28.             }
  29.             else if (profession == "SoftUni Student")
  30.             {
  31.                 price = quantity * beer;
  32.             }
  33.             else
  34.             {
  35.                 price = quantity * tea;
  36.             }
  37.             Console.WriteLine($"The {profession} has to pay {price:f2}.");
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment