Advertisement
Spocoman

06. Flower Shop

Aug 24th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FlowerShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int magnolias = Integer.parseInt(scanner.nextLine());
  7.         int hyacinths = Integer.parseInt(scanner.nextLine());
  8.         int roses = Integer.parseInt(scanner.nextLine());
  9.         int cacti = Integer.parseInt(scanner.nextLine());
  10.         double gift = Double.parseDouble(scanner.nextLine());
  11.  
  12.         double total = (magnolias * 3.25 + hyacinths * 4 + roses * 3.5 + cacti * 8) * 0.95;
  13.  
  14.         if (total >= gift){
  15.             System.out.printf("She is left with %d leva.", (int)Math.floor(total - gift));
  16.         } else {
  17.             System.out.printf("She will have to borrow %d leva.", (int)Math.ceil(gift - total));
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement