Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This assignment, based on Vending Machine we did in class, you are to now vend s

ID: 3532242 • Letter: T

Question

This assignment, based on Vending Machine we did in class, you are to now vend six different snacks. The Vending Machine has a capacity of storing up to 100 packs of snacks. Therefore, emulating the real vending machine, it is appropriate to allocate a fixed number of packages to each type of snacks. For example, you can stock 20 packs of Chips, 20 packs of M&Ms, 16 packs of Popcorn, 16 packs of Snickers, 14 packs of Gum, 14 packs of Crackers for a total of 100 packs of snacks. The following is one possible solution, and it is not the only solution. Your application can be different from this write up.

Your task for this assignment is to define multiple classes via inheritance. Your classes should implement various

Explanation / Answer

public class VendingMachineTester
{
public static void main ( String[] args )
{
boolean doAgain = true;
char choice;
VendingMachine myMachine = new VendingMachine();
Snack mySnack = new Snack();


while ( doAgain )
{
System.out.println();
System.out.println( "Options:" );
System.out.println();
System.out.println( "1] Exit" );
System.out.println( "2] Insert money" );
System.out.println( "3] Vend soda" );
System.out.println( "4] Vend snacks" );
System.out.println( "5] Restock vending machine" );
System.out.println();
System.out.print( "Choice: " );
choice = Keyboard.readChar();

if ( choice == '1' )
doAgain = false;

if ( choice == '2' )
{
System.out.print( "Enter amount of cents to insert: " );
double cents = Keyboard.readDouble();
myMachine.addMoney ( cents );
}

if ( choice == '3' )
{
System.out.println( "Vend a soda and get change." );
myMachine.vend();
}

if ( choice == '4' )
System.out.println ( "Vend a snack and get change." );


if ( choice == '5' )
{
System.out.println ( "Restock vending machine." );
myMachine.restock();
}

}//end while

System.out.println();
System.out.println();
System.out.println( "Thanks for using my vending machine." );
}//end method main
}//end class

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote