Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ChristmasMarket {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double neededMoney = Double.parseDouble(scanner.nextLine());
- int fantasyCount = Integer.parseInt(scanner.nextLine());
- int horrorCount = Integer.parseInt(scanner.nextLine());
- int romanceCount = Integer.parseInt(scanner.nextLine());
- double fantasyPrice = 14.9;
- double horrorPrice = 9.8;
- double romancePrice = 4.3;
- double totalPrice = fantasyCount * fantasyPrice + horrorCount * horrorPrice + romanceCount * romancePrice;
- totalPrice *= 0.8;
- if (totalPrice >= neededMoney ){
- double rest = totalPrice - neededMoney;
- int temp = (int)Math.floor(rest * 0.1);
- totalPrice -= temp;
- System.out.printf("%.2f leva donated.%n", totalPrice);
- System.out.printf("Sellers will receive %d leva.", temp);
- }else{
- System.out.printf("%.2f money needed.", neededMoney - totalPrice);
- }
- }
- }
Add Comment
Please, Sign In to add comment