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