Guest User

Garfileld

a guest
Feb 28th, 2016
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.15 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         var money = double.Parse(Console.ReadLine());
  7.         var rate = double.Parse(Console.ReadLine());
  8.         var pizzaPrice = double.Parse(Console.ReadLine());
  9.         var lasagnaPrice = double.Parse(Console.ReadLine());
  10.         var sandwichPrice = double.Parse(Console.ReadLine());
  11.         var pizzaQuantity = double.Parse(Console.ReadLine());
  12.         var lasagnaQuantity = double.Parse(Console.ReadLine());
  13.         var sandwichQuantity = double.Parse(Console.ReadLine());
  14.  
  15.         var spentForPizza = (pizzaPrice / rate) * pizzaQuantity;
  16.         var spentForLasagna = (lasagnaPrice / rate) * lasagnaQuantity;
  17.         var spentForSandwich = (sandwichPrice / rate) * sandwichQuantity;
  18.         var 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.         }
  25.         else
  26.         {
  27.             Console.WriteLine("Garfield is hungry. John is a badass. Money needed: ${0:0.00}." ,Math.Abs(money - x));
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment