Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Hungry_Garfield {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- double moneyInDollars = Double.parseDouble(console.nextLine());
- double exchangeRate = Double.parseDouble(console.nextLine());
- double pizzaPrice = Double.parseDouble(console.nextLine());
- double lasagnaPrice = Double.parseDouble(console.nextLine());
- double sandwichPrice = Double.parseDouble(console.nextLine());
- double pizzaQuantity = Double.parseDouble(console.nextLine());
- double lasagnaQuantity = Double.parseDouble(console.nextLine());
- double sandwichQuantity = Double.parseDouble(console.nextLine());
- double moneyInLeva = moneyInDollars * exchangeRate;
- double orderedFood = (pizzaPrice * pizzaQuantity) +
- (lasagnaPrice * lasagnaQuantity) + ( sandwichPrice * sandwichQuantity);
- double moneyLeft = moneyInLeva - orderedFood;
- if(moneyLeft >= 0){
- moneyLeft = Math.abs(moneyLeft / exchangeRate);
- System.out.printf("Garfield is well fed, John is awesome. Money left: $%.2f.", moneyLeft );
- }else{
- moneyLeft = Math.abs(moneyLeft / exchangeRate);
- System.out.printf("Garfield is hungry. John is a badass. Money needed: $%.2f.", moneyLeft );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment