Advertisement
Dakufuren

Untitled

Oct 24th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package sem3task3;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11.  *
  12.  * @author Albin
  13.  */
  14. public class Sem3Task3 {
  15.  
  16.     /**
  17.      * @param args the command line arguments
  18.      */
  19.     public static void main(String[] args) {
  20.         int truckvolume;
  21.         int x = 0; //bigbag counter
  22.         int y = 0; //mediumbag counter
  23.         int z = 0; //smallbag counter
  24.        
  25.         Bags bags = new Bags();
  26.         Scanner scan = new Scanner(System.in);
  27.        
  28.         System.out.println("What is the Volume of the truck? cm3");
  29.         truckvolume = scan.nextInt();
  30.        
  31.         while(truckvolume >= bags.getBigBag()){
  32.             truckvolume = truckvolume - bags.getBigBag();
  33.             x++;
  34.         }
  35.  
  36.         while(truckvolume >= bags.getMediumBag()){
  37.             truckvolume = truckvolume - bags.getMediumBag();
  38.             y++;
  39.         }
  40.        
  41.         while(truckvolume >= bags.getSmallBag()){
  42.             truckvolume = truckvolume - bags.getSmallBag();
  43.             z++;
  44.         }
  45.        
  46.         System.out.println("Big Bags Fit: " + x);
  47.         System.out.println("Medium Bags Fit: " + y);
  48.         System.out.println("Small Bags Fit: " + z);
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement