Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class FlowerShop {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int magnolias = Integer.parseInt(scanner.nextLine());
- int hyacinth = Integer.parseInt(scanner.nextLine());
- int roses = Integer.parseInt(scanner.nextLine());
- int cactus = Integer.parseInt(scanner.nextLine());
- double present = Double.parseDouble(scanner.nextLine());
- double magnoliasPrice = magnolias * 3.25;
- double hyacinthPrice = hyacinth * 4;
- double rosesPrice = roses * 3.50;
- double cactusPrice = cactus * 8;
- double money = magnoliasPrice + hyacinthPrice + rosesPrice + cactusPrice;
- double rate = money * 0.05;
- double profit = money - rate;
- if (present > profit){
- int moneyDifferent = (int) Math.ceil(present - profit);
- System.out.printf("She will have to borrow %d leva.", moneyDifferent);
- }
- else {
- int moneyDifferent = (int) Math.floor(profit - present);
- System.out.printf("She is left with %d leva.", moneyDifferent);
- }
- }
- }
Add Comment
Please, Sign In to add comment