Advertisement
Sim0o0na

2. Shopping

Mar 12th, 2018
2,526
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double budget = double.Parse(Console.ReadLine());
  14.             int choco = int.Parse(Console.ReadLine());
  15.             double milk = double.Parse(Console.ReadLine());
  16.  
  17.             double priceChoco = choco * 0.65;
  18.             double priceMilk = milk * 2.70;
  19.             double tangerine = Math.Floor(choco * 0.65);
  20.             double priceTangerine = tangerine * 0.20;
  21.             double priceAll = priceChoco + priceMilk + priceTangerine;
  22.  
  23.             if (budget >= priceAll)
  24.             {
  25.                 Console.WriteLine($"You got this, {budget - priceAll:f2} money left!");
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine($"Not enough money, you need {priceAll - budget:f2} more!");
  30.             }
  31.         }
  32.     }      
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement