Advertisement
fbinnzhivko

Hungy Garfiled

Apr 22nd, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         decimal money = decimal.Parse(Console.ReadLine());
  7.         decimal rate = decimal.Parse(Console.ReadLine());
  8.         decimal pizzaPrice = decimal.Parse(Console.ReadLine());
  9.         decimal lasagnaPrice = decimal.Parse(Console.ReadLine());
  10.         decimal sandwichPrice = decimal.Parse(Console.ReadLine());
  11.         decimal pizzaQuantity = decimal.Parse(Console.ReadLine());
  12.         decimal lasagnaQuantity = decimal.Parse(Console.ReadLine());
  13.         decimal sandwichQuantity = decimal.Parse(Console.ReadLine());
  14.  
  15.         decimal spentForPizza = (pizzaPrice / rate) * pizzaQuantity;
  16.         decimal spentForLasagna = (lasagnaPrice / rate) * lasagnaQuantity;
  17.         decimal spentForSandwich = (sandwichPrice / rate) * sandwichQuantity;
  18.         decimal x = spentForLasagna + spentForPizza + spentForSandwich;
  19.  
  20.         if (x <= money)
  21.         {
  22.             Console.WriteLine("Garfield is well fed, John is awesome. Money left: ${0:0.00}.", money - x);
  23.         }
  24.         else if (x > money)
  25.         {
  26.             Console.WriteLine("Garfield is hungry. John is a badass. Money needed: ${0:0.00}.", Math.Abs(money - x));
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement