|
Post by Admin on Jul 13, 2015 22:13:52 GMT
Post any discussion questions concerning advanced programming.
|
|
|
Post by czar on Jul 27, 2015 15:04:10 GMT
This is a test
|
|
|
Post by amil45 on Sept 1, 2015 13:09:39 GMT
On Exercise 7-3, is there a way we can open LOGICAL2.CPP? Or am I doing the wrong thing all together?
|
|
|
Post by Ruyi.Nhuy on Sept 1, 2015 15:12:36 GMT
I'm thinking we just do a Word document analyzing the output.
|
|
|
Post by Sebastian on Sept 6, 2015 16:04:20 GMT
Yes just use a word document analyzing the output, or you can actually create the file. Students do it either way, but the intent is to give you an introduction.
|
|
|
Post by cristian on Sept 16, 2015 14:58:57 GMT
I created a function that uses menu shortcuts and user input to calculate a final cost. This is only my function, not the full program. The problem that I am having is that I can only enter one character and hit enter. It goes to the next line but does not let me enter any other info or get a return amount. Any suggestions? insert code here
int Total() { char order[21];//orders variable
int total_cost=0;
std::cin>>order;//takes in an order
while (order!="T");//while the total is NOT being called goes through the statement {
if(order=="S","C","B","R","L") //trys to find menu items in order {total_cost=total_cost+ 1;}//If an item is called adds a dollar, Could have used total_cost++, or total_cost+=1
return total_cost;//returns cost }}
|
|
|
Post by amil45 on Sept 18, 2015 13:04:54 GMT
Can you post the rest of the program? I'm pretty sure the problem is somewhere outside the function.
|
|
|
Post by Ruyi.Nhuy on Sept 18, 2015 15:04:44 GMT
Try looping the entire function instead of the looping the case inside the function. Try putting this format into the main function:
do function(); while (order!="T");
|
|
|
Post by cristian on Sept 18, 2015 15:04:55 GMT
The rest of my code is mainly just a menu, and then a total.
int _tmain(int argc, _TCHAR* argv[]) { int x;
std::cout<<"S-sandwich $1 \n";//Simple menu setup std::cout<<"C-chips $1 \n"; std::cout<<"B-Brownie $1 \n"; std::cout<<"R-Regular drink $1 \n"; std::cout<<"L-Large drink $1 \n"; std::cout<<"B-Brownie $1 \n"; std::cout<<"R-Regular drink $1 \n";
total()*.06=x;// goes to total function which returns added cost of items, then multiplies by sales tax
std::cout<<"Your total is "<<x; system("pause"); return 0; }
|
|
|
Post by Ruyi.Nhuy on Sept 18, 2015 15:06:18 GMT
Also, put the menu display into my function as well, and used a case statement. My main statement is only what I posted above.
|
|
|
Post by cristian on Sept 18, 2015 15:08:04 GMT
Thanks for the advice I'll give it a shot.
|
|
|
Post by cristian on Sept 18, 2015 15:26:02 GMT
Thanks for the help, I had to mess around with a bit but the advice helped me out.
|
|