BubaLazi

p01_HugryGarfield

Mar 14th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Hungry_Garfield {
  4.     public static void main(String[] args) {
  5.         Scanner console = new Scanner(System.in);
  6.  
  7.         double moneyInDollars = Double.parseDouble(console.nextLine());
  8.         double exchangeRate = Double.parseDouble(console.nextLine());
  9.  
  10.         double pizzaPrice = Double.parseDouble(console.nextLine());
  11.         double lasagnaPrice = Double.parseDouble(console.nextLine());
  12.         double sandwichPrice = Double.parseDouble(console.nextLine());
  13.  
  14.         double pizzaQuantity = Double.parseDouble(console.nextLine());
  15.         double lasagnaQuantity = Double.parseDouble(console.nextLine());
  16.         double sandwichQuantity = Double.parseDouble(console.nextLine());
  17.  
  18.         double moneyInLeva = moneyInDollars * exchangeRate;
  19.         double orderedFood = (pizzaPrice * pizzaQuantity) +
  20.                 (lasagnaPrice * lasagnaQuantity) + ( sandwichPrice * sandwichQuantity);
  21.  
  22.         double moneyLeft = moneyInLeva - orderedFood;
  23.  
  24.         if(moneyLeft >= 0){
  25.             moneyLeft = Math.abs(moneyLeft / exchangeRate);
  26.             System.out.printf("Garfield is well fed, John is awesome. Money left: $%.2f.", moneyLeft );
  27.         }else{
  28.             moneyLeft = Math.abs(moneyLeft / exchangeRate);
  29.             System.out.printf("Garfield is hungry. John is a badass. Money needed: $%.2f.", moneyLeft );
  30.  
  31.         }
  32.  
  33.     }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment