Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int students = Integer.parseInt(scanner.nextLine());
- double pricePackageFlour = Double.parseDouble(scanner.nextLine());
- double priceSingleEgg = Double.parseDouble(scanner.nextLine());
- double priceOneApron = Double.parseDouble(scanner.nextLine());
- double priceSetStudent = pricePackageFlour + 10 * priceSingleEgg + priceOneApron;
- double priceSetAllStudents = 0;
- double additionalCountAprons = Math.ceil(0.2 * students);
- //System.out.println(countAprons);
- for (int i = 1; i <= students; i++) {
- if (i % 5 == 0) {
- priceSetStudent = 10 * priceSingleEgg + priceOneApron;
- } else {
- priceSetStudent = pricePackageFlour + 10 * priceSingleEgg + priceOneApron;
- }
- priceSetAllStudents += priceSetStudent;
- }
- double sumNeeded = priceSetAllStudents + (additionalCountAprons * priceOneApron);
- if (sumNeeded <= budget) {
- System.out.printf("Items purchased for %.2f$.", sumNeeded);
- } else if (sumNeeded > budget) {
- double moneyNotEnough = sumNeeded - budget;
- System.out.printf("%.2f$ more needed.", moneyNotEnough);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement