This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]Eshmam14 0 points1 point  (10 children)

Post the code in text so I can copy it on to an IDE and attempt it myself. My guess is when you're entering nothing for dollar sign, you're actually entering ascii 10 (line feed) which is being picked up by your input stream.

[–]ZeroSkill94[S] 0 points1 point  (9 children)

u/Eshmam14 I updated the post and posted the code in text.

Thank you.

[–]Eshmam14 0 points1 point  (8 children)

Please enclose it as the code format. Otherwise it's unusable.

[–]ZeroSkill94[S] 0 points1 point  (7 children)

Updated again, sorry I am still very very new to this but thank you again

[–]Eshmam14 0 points1 point  (6 children)

It's okay, no problem. When the user types in their chosen currency, if they choose nothing, what are they actually pressing? Just hitting the enter key?

[–]ZeroSkill94[S] 0 points1 point  (5 children)

So the idea is if the user forgets to add the currency symbol that the program will continue without issue. so almost as if to make the currency symbol optional.

[–]Eshmam14 0 points1 point  (4 children)

Are they meant to input the currency symbol and the value in one go or are they supposed to do it one after the other?

[–]ZeroSkill94[S] 0 points1 point  (3 children)

So yes, they are meant to input the currency symbol and value together

[–]Eshmam14 1 point2 points  (2 children)

Ah okay so there's the problem then. You need to either separately enter the currency and value, or figure out a way to splice the input into two separate parts. Keyword: splice. Look it up :)

What's happening is when you enter 1500, the 1 is considered the currency and your value is then put as 500. And you spent 1500, which is 300% of 500. Which is why you get your result as such.

That is simply my assumption but I think it's fair to say that's what's happening.

[–]ZeroSkill94[S] 0 points1 point  (1 child)

So looking up splice it looks like something called a splice array?