Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exam3September2017;
- import java.util.Scanner;
- public class P04_Cake {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int width = Integer.parseInt(scanner.nextLine());
- int length = Integer.parseInt(scanner.nextLine());
- int pieces = width * length;
- for (int i = 0; i <= 1000; i++) {
- String takePieces = scanner.nextLine();
- if ("Stop".equalsIgnoreCase(takePieces)) {
- System.out.printf("%d pieces are left.", pieces);
- break;
- } else {
- pieces -= Integer.valueOf(takePieces);
- if (pieces < 0) {
- System.out.printf("No more cake left! You need %d pieces more.", Math.abs(pieces));
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement