Advertisement
Spocoman

Beer and chips

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