How JustAnswer Works:
  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.
Ask LogicPro Your Own Question
LogicPro, Engineer
Category: Homework
Satisfied Customers: 13033
Experience:  Expert in Java C++ C C# VB Javascript Design SQL HTML
Type Your Homework Question Here...
LogicPro is online now
A new question is answered every 9 seconds

Today in class I was asked to do the following: Write a class

This answer was rated:

Today in class I was asked to do the following:
Write a class Automaton which implements a basic vending machine. The machine has three things to o er: water, cola, and juice. The prices
are 10, 12, and 15, respectively. The customer selects this by typing W, C, or J re-
spectively. The the customer inserts coins with values 1, 2, 5, 10, or 20, and types
"SELECT" to complete the transaction. Depending on whether the customer paid to
much, exact, or too few, the output of the machine is like in the following example.
W Paid 15 change is 5
J Paid 15 thanks
C Not paid enough . Return 11
This example was generated by the following input:
The string TERMINATE makes the program write DONE and terminate. If an error occurs,
e.g. an illegal value of a coin or the selected item. The machine writes ERROR and
terminates, e.g., by System.exit(0).
Your program should read from standard input, for example using a scanner.
Welcome here.
My name is XXXXX XXXXX I will help you.
What is the deadline?
Customer: replied 3 years ago.

Tomorrow, Is that possible?

yes, I will provide you answer ASAP.
Customer: replied 3 years ago.

Thank you

Customer: replied 3 years ago.

How's it going?

do you have an ETA? :)

Please check back in 5-6 hours.
If you have any file(s). Zip, upload the file to and post download link here.

Download answer from here:
Please let me know if anything else is required in this.

You can ask me again using "For LogicPro only" at the start of your questions like other customers to get instant answers.
It will ensure that question is for me.
Please bookmark my profile page:
so you can come back and ask me a question anytime.
Remember, if you need anything else, we can continue the conversation until you’re satisfied and rate my answer as excellent. I can address follow up questions at no extra charge and I’m always here to help.
Thank you for using this site!
LogicPro and 6 other Homework Specialists are ready to help you
Customer: replied 3 years ago.

Hey thanks for the answer, my teacher also wants me to commentate what is happening i.e explain which commands we use. He wants a little text between 5-10 lines explaining how the program is structures. I hope you can help me with this last thing


please wait.
Download again from here:
Customer: replied 3 years ago.

Here is an example of what my teacher wants:

Program structure (detailed)
We used a number of static methods to structure the program.
Method main contains the main program control. It basically consists of a while-loop
that performs two steps: Fetching the next number to be factorized and initiating the
factorization. In order to initialize the loop condition, the rst integer is fetched before
the loop. Termination is achieved when a ceratin integer value is supplied (in our case
􀀀1 (actually, any number less than 2)).
Method int getNumber() fetches and returns the next integer from the standard input.
We use an instance of Scanner for this purpose. The method uses Scanner-class' look-
ahead capability (hasNextInt) to ensure that the user supplied an integer. If that is not
the case, a warning is issued and the termination value is returned.
Method factorize(int n) receives the number to be factorized as formal parameter. It
then performs the decomposition into prime factors described above. A while-loop is used
which terminates when the value of n drops under 2. The method also prints the factors.
The least factor is provided by method findFactor.
Method int findFactor(int n) receives a number as formal parameter and returns its
least factor. It nds the least factor as described above by checking the remainder of
the division. A while-loop is used which terminates when the remainder is 0 for the rst
time. This is guaranteed to happen, because: n  f = 2 at start, f is increased in each
iteration of the loop, the remainder becomes 0 at latest when f = n.



I will review it and reply you ASAP.
Customer: replied 3 years ago.

Thanks :) one last thing and I will you give you the highest rating!

I can't seem to test the Vending Machine. Could you use some random number lets say we pick w and we have a 20 coin, could you fill out the variable so i can see where to input them ?


thanks alot

Will it be ok if I provide you an output screenshot?
Customer: replied 3 years ago.

I just need to know where to input the money and the type of drink so if you can provide that in a screen shot yes :)

Here is the output:
Enter W, C or J for Water, Cola or Juice: W

Not paid enough . Balance 3

Paid 10 change is 2

Enter W, C or J for Water, Cola or Juice:

Entries in bold are the user input.

Customer: replied 3 years ago.

Where do I input 2 and 5 ?

After inputing item choice (W, C or J)
Customer: replied 3 years ago.

so in one line Enter W, C or J for Water, Cola or Juice: W,2,5 ?

Run in the same manner, as I provided you sample input/output.

Are you able to execute the program?
Customer: replied 3 years ago.




his is what i did input then


while (true) {

System.out.print("Enter W, C or J for Water, Cola or Juice: w");
Not paid enough . Balance 3
Paid 10 change is 2
String item = sc.nextLine();
int itemCost = 0;
if (item.equalsIgnoreCase("W")) {

Can you provide me output screenshot, how you are executing it?

Program is exactly as per the instructions.
Customer: replied 3 years ago.


any chance you can upload a screenshot of how you have done it?


Do not write anything in the code, which I gave you.
You can submit code as it is, It is exactly as per the instructions.

Customer: replied 3 years ago.

ah thanks I feel so stupid now :)

really good and effective help you gave me thank you.


You need to spend $3 to view this post. Add Funds to your account and buy credits.

Related Homework Questions