Advertisement
VladoG

PB-BG-Oct2018-ExamPrep-02.BeerAndChips

Nov 24th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02.BeerAndChips
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string fanName = Console.ReadLine();
  10.             double budget = double.Parse(Console.ReadLine());
  11.             int bottleBeer = int.Parse(Console.ReadLine());
  12.             int chipsPacks = int.Parse(Console.ReadLine());
  13.  
  14.             double chipsPrice = ((bottleBeer * 1.2) * 0.45) * chipsPacks;
  15.             chipsPrice = Math.Ceiling(chipsPrice);
  16.             double totalSum = bottleBeer * 1.2 + chipsPrice;
  17.  
  18.             if (budget >= totalSum)
  19.             {
  20.                 Console.WriteLine($"{fanName} bought a snack and has {(budget - totalSum):F2} leva left.");
  21.             }
  22.             else
  23.             {
  24.                 Console.WriteLine($"{fanName} needs {(totalSum - budget):F2} more leva!");
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement