Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package sem3task3;
- import java.util.Scanner;
- /**
- *
- * @author Albin
- */
- public class Sem3Task3 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int truckvolume;
- int x = 0; //bigbag counter
- int y = 0; //mediumbag counter
- int z = 0; //smallbag counter
- Bags bags = new Bags();
- Scanner scan = new Scanner(System.in);
- System.out.println("What is the Volume of the truck? cm3");
- truckvolume = scan.nextInt();
- while(truckvolume >= bags.getBigBag()){
- truckvolume = truckvolume - bags.getBigBag();
- x++;
- }
- while(truckvolume >= bags.getMediumBag()){
- truckvolume = truckvolume - bags.getMediumBag();
- y++;
- }
- while(truckvolume >= bags.getSmallBag()){
- truckvolume = truckvolume - bags.getSmallBag();
- z++;
- }
- System.out.println("Big Bags Fit: " + x);
- System.out.println("Medium Bags Fit: " + y);
- System.out.println("Small Bags Fit: " + z);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement