Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class E02christmasMarket {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double targetMoney = Double.parseDouble(scanner.nextLine());
- double fantasyBooks = Double.parseDouble(scanner.nextLine());
- double horrorBooks = Double.parseDouble(scanner.nextLine());
- double romanceBooks = Double.parseDouble(scanner.nextLine());
- double fantasyBookPrice = 14.90;
- double horrorBooksPrice = 9.80;
- double romanceBooksPrice = 4.30;
- double CharityMoney = ((fantasyBookPrice * fantasyBooks)+(horrorBooks *horrorBooksPrice)+ (romanceBooks * romanceBooksPrice)) * 0.80;
- if (CharityMoney >= targetMoney){
- double diff = CharityMoney - targetMoney;
- double sallers = Math.floor(diff * 0.10);
- double totalFinal = CharityMoney - sallers;
- System.out.printf("%.2f leva donated.%n", totalFinal);
- System.out.printf("Sellers will receive %.0f leva.", sallers);
- }
- else {
- double diff = targetMoney - CharityMoney;
- System.out.printf("%.2f money needed.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment