Need help understanding question

Hi, I'm not very good at english and I need help understanding c in this question. I understand the other two fine and I've already done the first one (which was to correct the formatting) and a little bit of the second one but I just wanted to understand the third one too thanks I have provided pictures of my code so far so you know what is going on
No description
No description
No description
15 Replies
JavaBot
JavaBot15mo ago
This post has been reserved for your question.
Hey @B3251! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Larry_springboot
Larry_springboot15mo ago
Validate all the user inputs That's creating probably a check for each user input
B3251
B3251OP15mo ago
hmm is that not in the code already i think i figured it out, would it be adding an if/else statement before the guessing if/else-if statements indicating on whether its an integer or not @Larry_springboot
dan1st
dan1st15mo ago
input validation means you need to check whether the inputs are correct i.e. your program shouldn't allow invalid inputs
B3251
B3251OP15mo ago
i think i got it like i need to make sure its an int the input
Larry_springboot
Larry_springboot15mo ago
👍
dan1st
dan1st15mo ago
for example
B3251
B3251OP15mo ago
hold on can i send my code i just need some advice
B3251
B3251OP15mo ago
here is what i added, and here is the error message i get when i input a non integer but i want it to not consider the program to be finished yet so that it prints an error message and goes back to asking for an integer
No description
No description
B3251
B3251OP15mo ago
could you let me know what i did wrong
dan1st
dan1st15mo ago
well you are calling nextInt before hasNextInt the nextInt can fail already
B3251
B3251OP15mo ago
wait is that not what i do? I was thinking that it calls nextint but if nextint is not an int it would fail
dan1st
dan1st15mo ago
hasNextInt checks the next input
B3251
B3251OP15mo ago
yeah uh damn sorry im confused got it nevermind
JavaBot
JavaBot15mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?