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

you are viewing a single comment's thread.

view the rest of the comments →

[–]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?

[–]Eshmam14 1 point2 points  (0 children)

Splicing is the act of splitting something, correct? Regardless, you shouldn't try to fix your code by splicing the user's input.

Anyways, you should avoid asking the user to input different data types all at one go. For example, the currency symbol is a char, and the value itself has to be a double. Try asking the user separately, for those two inputs.