Hi im so close to finishing my code and i just need help tweaking the last bits - beginner level
Basically im using if and else statements... etc.. and when i run my code it works how i want it to... it says what flavour of ice do you want then you input vanilla, chocolate or strawberry.... now heres where my code is slightly off on what i want it to do.... when i put a different flavour it should finish with we dont have that flavour but instead it goes onto the next line of code which is how many scoops do you want and when i put the no. of scoops then it says we dont have that flavour but i want it to say we dont have that flavour before it runs to the next line of code.
57 Replies
⌛
This post has been reserved for your question.
Hey @StremesJ! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
you are missing a "}"
btw, you're making some strange things
if scoops < 0 would be the "We don't sell just a cone"
I made it on Java, it should give you some clues of what's happening
btw I've changed some things for performance upgrades
like changing double to Float and removing unnecessary println lines
also changed the ifs & else if with a switch
for better performance you can change this to the beginning:
Hope It helps ^^!! Anything else, just say it @StremesJ
thanks so much
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
np, anything else?
thats all for now
perfect ^^
JavaBot#9523
Recent Warns
<@743072402702860358> has
0
active warns with a total of 0
severity.im so sorry. If you are busy then no worries but actually... im wondering you said you used switch case instead but if i wanted to do it with the if and else way would you be able to show me how it would be done if thats not too much trouble?
Yeah, I'm actually not on the Pc but it's simple
ok
thanks
You know what? On my way to the Pc 🙂
😄
I hate to write on my phone
thats so fair
its tedious
im new to java btw
so im trying to learn stuff
yeah, for the way you typed your code I gessed
lol
but yh basically just need this to work
Should be smth like this
so you define all the variables within a print statement? why is that
wait nvm
also if can you do it without using floats?
some recommendations.
1. You are using few decimals so change
double
to float
, this is because double take much more space than float.
2. remove the Println on every if statement, just change the variable, u're gonna make the program run less code linesok
you can, just replace the float with double and on the vars
replace the "F" with a "D"
ok
have you used jshell ?
nope, I used JAVA itself, but it shouldn't be that hard, it's very similar
yh ok
can you pass me your jsh code pls?
not an screenshot
the code itself
ok what the file
just the file
btw
since im doing beginner level task
i dont get the why you put X: stuff
and such and such
or anoObjects?
do you mean in the println?
yh
well ik why you use println but theres the X:
thats because I have the Java extension pack on Visual Studio Code, that's what the system put
but you don't have to put it
ok thanks
look
this is the raw code
kk
the other thing is
jshell will shutdown with System.exit(0) is there a way to do it without jshell shutting down
so it prints thats too many scoops to fit in a cone without it shutting as well
I think this should work
ill test it in jshell
gimme a min
it didnt print the thats not a flavour mssg
?
yeah, but it would say it after you enter the scoops amount
i hate to be a pain is there any way to do it before
and is it quick fix
or pain in the ass fix
?
I mean, you can, it's easy but its gross haha, let me change it
oki ty
I think it should work
I haven't tryed myself cause I don't have JShell 🙃
let me know if it works
will do give me justa min
ok 2 things when i put how many scoops as 0 it printed 1.0 instead of you cant just have to cone - second thing is more just out of interest: when using System.exit(0); that causes jshell to crash it does print the mssg - does return: print the mssg and keep it open or will it not work
but i appreciate this so much
1. If you're typing "0" on the scoops is gonna give you an error because you just put < 0 instead of <= 0, so you're not including the 0.
2. It should close the program so, I think it's doing it's job
ok
cool
Look ponchisao thanks so much for the help
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
😄
np, hope you've resolved your doubts ^^
indeed 👍
😃
💤
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.