Well here is the directions for the problem: ( The class has just started and we are only 4 weeks in it so I do not think we have gotten to "string" yet. As of right now the unit is focusing on "if" and "else" commands. Also this unit is focusing on the logical connectives "&& and ||" I would assume the exercise wants me to use these commands to get my program run. Beyond that not much else has been introduced. I replaced the code like you suggested but now I am getting new errors in my compiler and not sure where to go from here James2250.
"Write a program that asks for the user to input an exercise and responds accordingly, based on the answer as shown in the following chart. Be sure to combine the conditions appropriately; do not make a separate "if" statement for each possible answer."
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 28
|
#include <iostream>
using namespace std;
int main()
{
string exercise;
cin >> exercise;
if ((exercise == "curl") || (exercise == "chinup"))
{
cout << "This exercise is for your biceps.";
}
cout << endl;
if ((exercise == "pushup") || (exercise == "press"))
{
cout << "This exercise is for your pecs.";
}
cout << endl;
if (exercise == "row")
{
cout << "This exercise is for your back.";
}
cout << endl;
if (exercise == deadLift)
{
cout << "This exercise is for your whole body.";
}
cout << endl;
}
|
Compiler Errors:
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(6): error C2371: 'exercise' : redefinition; different basic types
1> c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(5) : see declaration of 'exercise'
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(7): error C2088: '>>' : illegal for class
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(9): error C2446: '==' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(9): error C2040: '==' : 'int' differs in levels of indirection from 'const char [5]'
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(9): error C2446: '==' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(9): error C2040: '==' : 'int' differs in levels of indirection from 'const char [7]'
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(14): error C2446: '==' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(14): error C2040: '==' : 'int' differs in levels of indirection from 'const char [7]'
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(14): error C2446: '==' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(14): error C2040: '==' : 'int' differs in levels of indirection from 'const char [6]'
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(19): error C2446: '==' : no conversion from 'const char *' to 'int'
1> There is no context in which this conversion is possible
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(19): error C2040: '==' : 'int' differs in levels of indirection from 'const char [4]'
1>c:\users\administrator\documents\visual studio 2010\projects\chap05_proj5c\chap05_proj5c\chap05_proj5c.cpp(24): error C2065: 'deadLift' : undeclared identifier