vendingMachine | This is a full-stack app of a vending machine | Continuous Deployment library
kandi X-RAY | vendingMachine Summary
kandi X-RAY | vendingMachine Summary
This is a full-stack app of a vending machine
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of vendingMachine
vendingMachine Key Features
vendingMachine Examples and Code Snippets
Community Discussions
Trending Discussions on vendingMachine
QUESTION
using Atom again after a long time and I'm running into some problems. Made a js file with just this:
...ANSWER
Answered 2021-Apr-05 at 08:31java and javascript are different programming languages with about as much in common as Car and Carpet.
You have written Java but put it in a file with a file extension that marks it as JavaScript. Your IDE is trying to run it as if it were the latter and throwing errors because it is the former.
Java typically belongs in .java
files.
QUESTION
I have a segment of code here that runs partially. I am able to input both the characters (c, a, r) and numbers initially, but after entering a character input, the code no long accepts integer inputs. Why does this happen?
I think it has something to do with my try catch exception.
code:
...ANSWER
Answered 2020-Aug-14 at 21:41Once you've set flag to -1, it's never changed back to 0. The initialization you perform at the top of the file happens just once, before main is even called. So, after that, when you set it to -1 in the catch block, it never went to a part of the code that set it back to 0. As you saw, setting flag = 0 at the beginning of the while loop corrects that omission.
QUESTION
I am trying to use stroi
in my "vending machine" code below. I had a working vending machine before I tried to add a feature that allows users to enter characters ("c" for checkout, "a" for add, and "r" for remove) as well. Since my user input can be both int
and char
I realized I had to convert strings to numbers. I have checked references but none give an example of how to use it with vectors. Can someone please help?
Currently, there is an error located at the int myint1 = stoi(item);
line in the if
statement in the main. It says "use of undeclared identifier 'i'."
Note: I am fixing my code so it does not run. But when it did, the code breaks after 2 user inputs and I am not sure why.
Here is an example of what I am trying to code:
Vending machine:
----Items----
(5 listed below)
what item would you like to buy? Enter "c" to checkout, "a" for add item and "r" for remove item.
-If user input is an integer, then run the enterSelection
function
-If user input is a character (c, a, or r) , then:
if "c" , then run checkout
function
if "a", What Item would you like to add and for what price? Then append to menuItems
and cost
accordingly.
if "r", what item would you like to remove (enter a number)? Then erase
the item from menuItems
.
Then print: "User input" has been added/removed from the menu.
When the menu is displayed again, the user edit will show.
And yes, I know there are many more problems with my code that I do not know how to fix.
Full Code:
...ANSWER
Answered 2020-Aug-13 at 23:24To answer your question, you can.
However you are not doing correctly, regardless, you wouldn't need all those conversions, you could compare item
directly with a char
or int
deppending on the type of input you ask for.
We can also continue with std::stoi
to convert the input to its int value, you must, however, guard for the aphabetic inputs, these will not be converted, of course, and error derived from this failed conversions should be prevented.
Semi-corrected code with comments:
QUESTION
I am working on the "checkout" process of my vending machine code. I want to write it so that the program will keep asking for the amount needed from the user until all the money is entered. However, this code segment does not completely work.
"Checkout" Segment of Code:
...ANSWER
Answered 2020-Aug-07 at 19:21In this loop:
QUESTION
I am progressing on my "vending machine" code where users are able to add an unlimited amount of items to the cart until they press 0 to checkout. I ran into a problem with the array cost[item]
in my "do-while" loop where it says "subscripted value is not an array, pointer, or vector." Could someone please help me with this?
I also have a few smaller problems if someone would like to help. Here are my main problems I ran into:
the press 0 to checkout part of the code - I think this problem is related to the
cost[item]
array problem I described above.how to get my menu prices to display 2 digit decimals - I am not sure where to put
cout << fixed << setprecision(2) << total;
in my code if that is the correct way of doing it.how to print a statement when "checking out" to display items with total cost.
my full code:
...ANSWER
Answered 2020-Aug-06 at 02:33I will try to help you sort out where you did mistakes:
- About cost[item]:
Maybe you already hear about "scope". It's about location of your variables, pointers, etc. In your program you declared
float cost[5] = {2, 3, 2.50, 1.50, 1};
in global scope. This scope is where you declare something outside the main function. This scope works in wherever in this file. But you also declaredfloat cost;
with the same name in local scope. Local scope works only where you declared this and deeper (in loops of this function, if-statements etc.); Compiler priority is for local variables(notice that compiler allows you to write same name of variables but with different scopes). I have correct your misstakes and add comments for all moments:
QUESTION
I am writing some code and ran into an error when I need to return multiple values to main()
from another function.
Here, I am trying to return item
and total
to the main()
function. However, I am getting a warning saying that item
has not been used, but I am using it in main()
, where it then says "use of undeclared identifier" along with total
.
Could someone help me with my syntax issue here?
...ANSWER
Answered 2020-Aug-05 at 02:03Use the below in your processSelection referencing https://www.geeksforgeeks.org/returning-multiple-values-from-a-function-using-tuple-and-pair-in-c/ from Mike.
QUESTION
I have a test class created. I need to run the test file using spring dependency injection . I am using the XML method.
How to define a bean for Inventory in your XML configuration?
Testfile constructor:
...ANSWER
Answered 2020-Jun-23 at 08:30Need to include the value that is in the constructor in the tag and other properties in the
tag in the
Inventory Class
as follows.
QUESTION
Working in Spring, and using H2 for now.
So, I have these two classes/Entities with their repositories working fine if I keep it simple.
Brand, which simply has a name and a price;
and VendingMachine, which has a model and some other properties;
BUT I need to implement this:
Different VendingMachines sell different Brands, for which they have a stock. The Brands it sells are determined when you instantiate the class.
So my idea is that the table for VendingMachines fields should look something like that:
MODEL////ID/////MAXCAPACITY////MAXBRANDS///BRAND01////BRAND02///BRAND03...
Where all the BRAND columns are the different Brands the machine sells, assigned at its instantiation as said before. The value will be an Integer.
My original idea was to send this data to the @Entity via a HashMap(Brand, Integer) but I don't know how to make it work once it tries to fit it into the JpaRepository, or even if it is possible this way.
Probably missing some magic Annotation I don't know.
Thanks, hope my question was well explained for everyone.
...ANSWER
Answered 2020-Mar-20 at 01:01Extract Brand as new table/entity(read about database normalization). And after just do one-to-many relationship with that entities(VendingMachines and Brand). would look like that:
QUESTION
this project i use do while loop with switch case to check the input case is not match or not. i run the code but the result not what i wanted. what i expect is if the user type the wrong case, the do while loop will loop back to the input where user need to enter the case.
here is the code
...ANSWER
Answered 2020-Mar-16 at 07:38From what I understood from your code. When you are giving the input as 5 it is giving invalid. After that it will go to the while statement and check the condition there. If you are inside the switch case and select any random case It will show you invalid. After that depending upon the number that you have entered.
If the number is less than 5, It will again go to switch case.
As it doesn't make sense as If you continue to provide correct input to it. The code will continue to execute making the balance going in the negative. this condition should be changed to
while(balance>1.2)
assuming that it is minimum amount that is necessary to buy a drink. This will check the condition after every drink and will hopefully do what you were hoping. On side Note : Make your code modular.
QUESTION
I have a query performance issue that I'm trying to solve in Django.
Environment:
- Django 2.2
- Python 3.6
- Postgresql 11
Example Models:
...ANSWER
Answered 2020-Jan-28 at 18:06I was able to solve this using custom SQL.
https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly
Raw SQL:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install vendingMachine
run npm install
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page