Else IF statements

Pages: 123
Feb 24, 2012 at 4:59am
u are awsome that fixed the error on the if side of the code but my else's are still underlined as errors
Feb 24, 2012 at 5:01am
That's because you have single quotes around your literals in your else ifs as well.
Feb 24, 2012 at 5:05am
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <string>
using namespace std;

int main()
{
	string exercise;

	cout << "Please enter an exercise: ";
	cin >> exercise;
	if( exercise == "curl" || exercise == "chinup");
	{
		cout << "This exercise is for your biceps. ";
	}
	else if(exercise == "pushup" || exercise == "press");
	{
		cout << "This exercise is for your pecs. ";
	}
	else if(exercise == "row");
	{
		cout << "This exercise is for your back. ";
	}
	else if(exercise == "dead lift");
	{
		cout << "This exercise is for your whole body";
	}
}

this is my code as it stands i dont completly understand what you just said
Feb 24, 2012 at 5:08am
what lines are the current errors on?
Feb 24, 2012 at 5:09am
15,19,23
Feb 24, 2012 at 5:10am
try taking out the else part, or is that required for the project?
Feb 24, 2012 at 5:11am
its needed for the program to run correctly
Feb 24, 2012 at 5:12am
you using Microsoft visual I take it
Feb 24, 2012 at 5:13am
yep
Feb 24, 2012 at 5:13am
try replacing else if with elif it works.in python not sure about C++
Feb 24, 2012 at 5:14am
no didn't work
Feb 24, 2012 at 5:16am
so what does the error say now, don't copy and paste tell what's in quotes
Feb 24, 2012 at 5:16am
Your problem is you have ';' after all your if/else if statements, remove them and it will work fine.
Feb 24, 2012 at 5:17am
remove the semi-colons ';' from the end of your if and else if conditionals.

 
	if( exercise == "curl" || exercise == "chinup");


Those don't belong there.
Last edited on Feb 24, 2012 at 5:19am
Feb 24, 2012 at 5:18am
wow good job fire draco didn't see that
Feb 24, 2012 at 5:22am
did it work?
Feb 24, 2012 at 5:40am
im trying it right now we'll see
Feb 24, 2012 at 6:14am
yeah it works perfictly thank you to all of you who helped me on this i appreciate it
Feb 24, 2012 at 6:17am
only one thing more to ask how can i get deadlift to go in as 2 words?

Feb 24, 2012 at 12:51pm
thats alot more complexity for little gain trust me
if you really want some kind of separation try putting a _
Pages: 123