Jump to content
Due to the significant updates that have taken place, you now need to login with your display name or e-mail address, NOT your login name. ×
Due to posts that are 5+ years old being rebuilt, some of the older BBCodes may not have converted properly but still be in the post. Most posts are unaffected but some using what was our custom BBCode (like [spoiler]) will be a bit broken. ×
Sign in to follow this  
PoorLepRecon

c++ homework help

Recommended Posts

I have a program assigned for my C++ class that I'm having some trouble with. I have a few syntax errors that are eluding me and I was wondering if someone might take a look and see if they can identify what the problem is. I believe part of my problem is the brackets around the else statements at lines 34, 43, 49.

 

-removed, thanks for help

 

 

 

The compiler errors I get currently are these.

compilererrors.png

 

 

 

My whole problem might just be I'm not doing my nested if/else statements syntactically correct, so if that's the case it should be easy for me to fix once I know how to correctly do it.


Forum Updates & Suggestions <------ Let your voice be heard!
Forum Games <------- Coolest place on Tip.It
Tip.It Forum Rules <------- Read them!

Share this post


Link to post
Share on other sites

You don't need to put a condition for else statements in C++, the else will be triggered automatically if the condition in the initial if statement or any else if statements following it is not met.

 

For example line 34 should read

else

instead of

else (cash>=129.95)

 

The error on 49 is being caused because you have curly braces in the else condition, but not in the initial if statement. If you're going to use any curly braces in a conditional block (if, else if, else) you need to use them in all of the statements before the one you want to use it in as well.

 

Also don't forget to CIN the amount of money the person has, right now you're not actually asking the user for that data. ;)

 

Hopefully that should clean up those compiler errors for you. :)


Tecmaster532.png
Tecmaster532.png
lm9dzxe3.png
Owner of the Quest Point Cape

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.