Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class ChristmasMarket {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double targetMoney = Double.parseDouble(scanner.nextLine());
- int fantasyBooksCount = Integer.parseInt(scanner.nextLine());
- int horrorBooksCount = Integer.parseInt(scanner.nextLine());
- int romanceBooksCount = Integer.parseInt(scanner.nextLine());
- double totalSum = 0;
- totalSum += fantasyBooksCount * 14.9;
- totalSum += horrorBooksCount * 9.80;
- totalSum += romanceBooksCount * 4.3;
- totalSum -= totalSum * 0.2;
- if (totalSum >= targetMoney) {
- double moneyAboveTarget = totalSum - targetMoney;
- double sellersSalary = moneyAboveTarget * 0.1;
- sellersSalary = Math.floor(sellersSalary);
- totalSum -= sellersSalary;
- System.out.printf("%.2f leva donated.%n", totalSum);
- System.out.printf("Sellers will receive %.0f leva.", sellersSalary);
- } else {
- System.out.printf("%.2f money needed.", targetMoney - totalSum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement