Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SuitcasesLoad {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double capacity = Double.parseDouble(scan.nextLine());
- boolean isFull = false;
- int couter =0;
- int counterSutecase =0;
- String input = scan.nextLine();
- while (!"End".equals(input)){
- double suitcase = Double.parseDouble(input);
- couter++;
- if(couter % 3 == 0){
- suitcase = suitcase * 1.1;
- }
- if(capacity >= suitcase){
- capacity -= suitcase;
- counterSutecase++;
- }else{
- isFull = true;
- break;
- }
- if(capacity > 0){
- input = scan.nextLine();
- }else{
- isFull = true;
- break;
- }
- }
- if(isFull){
- System.out.println("No more space!");
- }else{
- System.out.println("Congratulations! All suitcases are loaded!");
- }
- System.out.printf("Statistic: %d suitcases loaded.", counterSutecase );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement