Wurtz+Java+Codes

This simple program find out how many souvenirs you can fit in your suitcase using the souvenir's dimensions as well as the suitcase's.

import java.util.Scanner;

public class VacationPlanner { public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner kbd = new Scanner(System.in);

System.out.print("How tall is the souvenir?"); // Asks how tall the souvenir is.

double prizeHeight = kbd.nextDouble; // Lets the user enter in the height of the souvenir.

System.out.print("How wide is the souvenir?");

double prizeWidth = kbd.nextDouble;

System.out.print("How long is the souvenir?");

double prizeLength = kbd.nextDouble;

System.out.print("How tall is your suitcase?");

double caseHeight = kbd.nextDouble;

System.out.print("How wide is your suitcase?");

double caseWidth = kbd.nextDouble;

System.out.print("How long is your suitcase?");

double caseLength = kbd.nextDouble;

double prizeSize = prizeHeight * prizeWidth * prizeLength; // calculates the area (cubed) of the souvenir.

double caseSize = caseHeight * caseWidth * caseLength;

double prizeNumberOf = caseSize / prizeSize; // calculates how many souvenirs will fit in your suitcase.

System.out.print("You can fit " + prizeNumberOf + "souvenirs."); // Displays the number of souvenirs your suitcase can fit.

} }