Advertisement
braveheart1989

Garfield

Feb 25th, 2016
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 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. class Program
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         decimal money = decimal.Parse(Console.ReadLine());
  12.         decimal rate = decimal.Parse(Console.ReadLine());
  13.         decimal pizzaPrice = decimal.Parse(Console.ReadLine());
  14.         decimal lasagnaPrice = decimal.Parse(Console.ReadLine());
  15.         decimal sandwichPrice = decimal.Parse(Console.ReadLine());
  16.         decimal pizzaQuantity = decimal.Parse(Console.ReadLine());
  17.         decimal lasagnaQuantity = decimal.Parse(Console.ReadLine());
  18.         decimal sandwichQuantity = decimal.Parse(Console.ReadLine());
  19.  
  20.         decimal moneyNeeds = pizzaPrice / rate * pizzaQuantity +
  21.             lasagnaPrice / rate * lasagnaQuantity + sandwichPrice / rate * sandwichQuantity;
  22.         //Console.WriteLine(moneyNeeds);
  23.         if (money >= moneyNeeds)
  24.         {
  25.             Console.WriteLine("Garfield is well fed, John is awesome. Money left: ${0:F2}.", Math.Abs(money - moneyNeeds));
  26.         }
  27.         else
  28.         {
  29.             Console.WriteLine("Garfield is hungry. John is a badass. Money needed: ${0:F2}.", Math.Abs(moneyNeeds-money));
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement