YavorGrancharov

HungryGarfield

Dec 17th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class HungryGarfield {
  3.     public static void main(String[] args) {
  4.         Scanner console = new Scanner(System.in);
  5.         double money = Double.parseDouble(console.nextLine());
  6.         double rate = Double.parseDouble(console.nextLine());
  7.         double pizzaPrice = Double.parseDouble(console.nextLine());
  8.         double lasagnaPrice = Double.parseDouble(console.nextLine());
  9.         double sandwichPrice = Double.parseDouble(console.nextLine());
  10.         int pizzaQuantity = Integer.parseInt(console.nextLine());
  11.         int lasagnaQuantity = Integer.parseInt(console.nextLine());
  12.         int sandwichQuantity = Integer.parseInt(console.nextLine());
  13.         double sum = (pizzaPrice / rate * pizzaQuantity) + (lasagnaPrice / rate * lasagnaQuantity) + (sandwichPrice / rate * sandwichQuantity);
  14.         double left = Math.abs(money - sum);
  15.         if (money >= sum) {
  16.             System.out.printf("Garfield is well fed, John is awesome. Money left: $%.2f.", left);
  17.         } else {
  18.             System.out.printf("Garfield is hungry. John is a badass. Money needed: $%.2f.", left);
  19.         }
  20.     }
  21. }
Add Comment
Please, Sign In to add comment