Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Soft_Uni_Varibles {
- public static void main(String[] args) {
- Scanner key = new Scanner(System.in);
- System.out.print("Number: ");
- int num = Integer.parseInt(key.nextLine());
- int capacity = 255;
- int quantity = 0;
- for (int i = 0; i < num; i++) {
- System.out.printf("How many liters do you want to pour?: %n");
- int liters = Integer.parseInt(key.nextLine());
- quantity += liters;
- if (quantity > capacity) {
- System.out.printf("Insufficient capacity! You poured %d liters.%n", quantity - liters);
- break;
- } else {
- System.out.printf("You poured %d liters.%n", quantity);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement