Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int days = Integer.parseInt(scanner.nextLine()),
- productPrice;
- String command;
- double dayCash = 0;
- for (int i = 0; i < days; i++) {
- int dayProducts = 0;
- dayCash += 60;
- while (true) {
- command = scanner.nextLine();
- if (command.equals("Day over")) {
- System.out.printf("Money left from today: %.2f.", dayCash);
- break;
- }
- productPrice = Integer.parseInt(command);
- if (productPrice <= dayCash) {
- dayCash -= productPrice;
- dayProducts++;
- }
- if (dayCash == 0) {
- System.out.print("Daily limit exceeded!");
- break;
- }
- }
- System.out.println(" You've bought " + dayProducts + " products.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement