Part Two: Download VendingChange.java (above). Run it and become familiar with the output. Essentially, you need...

70.2K

Verified Solution

Question

Programming

Part Two: Download VendingChange.java (above). Run itand become familiar with the output. Essentially, you need tocreate a user friendly GUI app using the code parameters ofVendingChange. Turn VendingChange.java into a GUI app.

1) Your program must display the inputdialog.
2) You must check that the data entered by the user follows therequired input. If not, your program must display an error dialogand exit.

3) If the input is valid, then your program must display amessage dialog similar to the one shown in listing 2.12, but themessage must pertain to VendingChange and not ChangeMaker. Yourmessage dialog must show the number of pennies, nickels, dimes andquarters.
4) Your program must exit when the user closes the output messagedialog.
5) Comment and document your program.

Complete the programming problems such that they produceoutput that looks similar to that shown in the text or upcomingclass presentations (in-class and Announcements). Tips and formulas(if any) will be discussed in class. Additional details will beprovided in class and Announcements.

add comments to code please.

import java.util.Scanner;public class VendingChange{  public static void main(String[] args)  {    Scanner keyboard = new Scanner(System.in);    System.out.println(\"Enter price of item\");    System.out.println        (\"(from 25 cents to a dollar, in 5-cent increments)\");    int originalAmount = keyboard.nextInt();    int change = 100 - originalAmount;    int quarters = change/25;    change = change%25;// remaining change after deducting quarters    int dimes = change/10;    change = change%10;// remaining change after deducting dimes, too    int nickels = change/5;    change = change%5;    int pennies = change;    //The grammar will be incorrect if any of the values are 1    //because the required program statements to handle that    //situation have not been covered, yet.      System.out.println        (\"You bought an item for \" + originalAmount        + \" and gave me a dollar,\");    System.out.println(\"so your change is\");    System.out.println(quarters + \" quarters,\");    System.out.println(dimes + \" dimes, and\");    System.out.println(nickels + \" nickel.\");  }}

Answer & Explanation Solved by verified expert
3.9 Ratings (434 Votes)
O U T P U TMessage Box Result windowJ A V A C O D EPackage declared is vendChangepackage vendChangeimport javaawtBorderLayoutimport javaawtEventQueueimport javaxswingJFrameimport javaxswingJPanelimport javaxswingborderEmptyBorderimport javaxswingJLabelimport javaxswingJOptionPaneimport javaawtFontimport javaxswingJTextFieldimport javaxswingJTextPaneimport javaxswingUIManagerimport javaawtSystemColorimport javaxswingJButtonimport javaawteventActionListenerimport javaawteventActionEventpublic class VendingChangeGUI extends JFrame private JPanel contentPane private JTextField textFieldPrice Launch the application public static void mainString args    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students