Advertisement
MladenKarachanov

FlowerShop

Jan 19th, 2024
1,075
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. package ProgrammingBasics2;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class FlowerShop {
  6.     public static void main(String[] args) {
  7.         Scanner scanner= new Scanner(System.in);
  8.         int magnolias = Integer.parseInt(scanner.nextLine());
  9.         int hyacinths = Integer.parseInt(scanner.nextLine());
  10.         int roses = Integer.parseInt(scanner.nextLine());
  11.         int cacti = Integer.parseInt(scanner.nextLine());
  12.         double aGift = Double.parseDouble(scanner.nextLine());
  13.         double sum = (magnolias*3.25)+(hyacinths*4.00)+(roses*3.50)+(cacti*8.00);
  14.         double taxes = sum*0.05;
  15.         double result = sum-taxes;
  16.         if(aGift <= result){
  17.             double diff = Math.abs(aGift-result);
  18.         System.out.printf("She is left with %.0f leva.",Math.floor(diff));
  19.         }else{
  20.             double diff1=Math.abs(aGift-result);
  21.             System.out.printf("She will have to borrow %.0f leva.",Math.ceil(diff1));
  22.         }
  23.  
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement