Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class p04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int widht = Integer.parseInt(scanner.nextLine());
- int height = Integer.parseInt(scanner.nextLine());
- int cakeArea = widht * height;
- while(true){
- String input = scanner.nextLine();
- if(input.equals("STOP")){
- break;
- }
- int pieces = Integer.parseInt(input);
- cakeArea -= pieces;
- if(cakeArea < 0){
- System.out.printf("No more cake left! You need %d pieces more.", Math.abs(cakeArea));
- return;
- }
- }
- System.out.printf("%d pieces are left.", cakeArea);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement