Advertisement
Silviyaa

FlowerShop

Feb 26th, 2021
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P07FlowerShop {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int numberMagnolias = Integer.parseInt(scanner.nextLine());
  8.         int numberZumbul = Integer.parseInt(scanner.nextLine());
  9.         int numberRose = Integer.parseInt(scanner.nextLine());
  10.         int numberCactus = Integer.parseInt(scanner.nextLine());
  11.         double price = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double magnolias = 3.35;
  14.         double zumbul = 4;
  15.         double rose = 3.50;
  16.         double cactus = 8;
  17.  
  18.         double sum =Math.floor(numberMagnolias * magnolias + numberZumbul * zumbul + numberRose * rose + numberCactus * cactus);
  19.      //   sum = sum - (sum * 0.05);
  20.         double tax = sum * 0.05; // данъци
  21.        double profit = sum - tax; //печалба
  22.         double lackPrice = Math.floor(Math.abs(profit - price)); //недостигнали пари
  23.         double remainingPrice = Math.ceil(Math.abs(price - profit));
  24.  
  25.         if(price >= sum)
  26.         {
  27.             System.out.printf("She will have to borrow %.0f leva." , remainingPrice);
  28.         }else{
  29.             System.out.printf("She is left with %.0f leva." , lackPrice-1);
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement