+ 1
Error
I'm trying to make a program that gives a few interview questions, there is a question that involves an integer to be inputted but it keeps giving me an error related to an operand here's the link to the code https://code.sololearn.com/cUQD29D4W1a9/?ref=app
8 Réponses
+ 2
PRAMOD JANA Look at the code now and try to run it and look at where money was at
0
money is an object name and you have initialized it with an integer that's why it is showing error...
0
PRAMOD JANA i also had an identifier by the name of "Amount" and i was still receiving errors
0
PRAMOD JANA i also had replaced Money.nextLine with Amount.nextLine when i was working on the program and still got errors
0
PRAMOD JANA The only way it would work is if i give Amount a value but i don't want to give it a value simply... let me show an example:
int amount = 0;
if (amount > 500)
you see that? it's a 0 of course it won't be greater than not to mention they will have to put any amount of money, and also no matter what you put as an input 0 will always be the default value so it's not going to work even if i didn't have money as an object
0
that's why i didn't want to add a value because that value will always be the default value and i only want it to calculate the number they input and say whether or not it's out of range instead of me having to input it for them
0
why you are taking input in print statement
0
you should take the input in amount