Advertisement
paykova

Cake

Oct 9th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Cake {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double l = Double.parseDouble(scanner.nextLine());
  8. double w = Double.parseDouble(scanner.nextLine());
  9. double volume = l * w;
  10. double result = 0;
  11. double pieces;
  12.  
  13. //String str = " ";
  14.  
  15. while (result <= volume) {
  16.  
  17. double num = Double.parseDouble(scanner.nextLine());
  18. result += num;
  19. if (str.equals("STOP")){
  20. String str = scanner.nextLine();
  21. pieces = Math.abs(result - volume);
  22. }
  23. } pieces = Math.abs(result - volume);
  24. System.out.println(pieces);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement