Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Proba {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String typeFlower = scanner.nextLine();
- int numFlower = Integer.parseInt(scanner.nextLine());
- int budget = Integer.parseInt(scanner.nextLine());
- double rosePrice = 5 * numFlower;
- double dahliaPrice = 3.8 * numFlower;
- double tulipsPrice = 2.8 * numFlower;
- double narcissusPrice = 3 * numFlower;
- double gladiolusPrice = 2.5 * numFlower;
- double totalPrice = 0.0;
- if (typeFlower.equalsIgnoreCase("roses") && numFlower > 80) {
- totalPrice = rosePrice - rosePrice * 0.1;
- } else if (typeFlower.equalsIgnoreCase("roses") && numFlower <= 80) {
- totalPrice = rosePrice;
- } else if (typeFlower.equalsIgnoreCase("dahlias") && numFlower > 90) {
- totalPrice = dahliaPrice - dahliaPrice * 0.15;
- } else if (typeFlower.equalsIgnoreCase("dahlias") && numFlower <= 90) {
- totalPrice = dahliaPrice;
- } else if (typeFlower.equalsIgnoreCase("tulips") && numFlower > 80) {
- totalPrice = tulipsPrice - tulipsPrice * 0.15;
- } else if ((typeFlower.equalsIgnoreCase("tulips") && numFlower <= 80)) {
- totalPrice = tulipsPrice;
- } else if (typeFlower.equalsIgnoreCase("narcissus") && numFlower < 120) {
- totalPrice = narcissusPrice + narcissusPrice * 0.15;
- } else if (typeFlower.equalsIgnoreCase("narcissus") && numFlower >= 120) {
- totalPrice = narcissusPrice;
- } else if (typeFlower.equalsIgnoreCase("gladiolus") && numFlower < 80) {
- totalPrice = gladiolusPrice + gladiolusPrice * 0.2;
- } else if (typeFlower.equalsIgnoreCase("gladiolus") && numFlower >= 80) {
- totalPrice = gladiolusPrice;
- }
- if (budget >= totalPrice) {
- double leftMoney = budget - totalPrice;
- System.out.printf("Hey, you have a great garden with %d %s and %.2f leva left.", numFlower, typeFlower, leftMoney);
- } else {
- double neededMoney = totalPrice - budget;
- System.out.printf("Not enough money, you need %.2f leva more.", neededMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement