The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> C Programming
|
menus
Discuss menus in the C Programming forum on Dev Shed. menus C programming forum discussing all C derivatives, including C#, C++, Object-C, and even plain old vanilla C. These languages are low level languages, and used on projects such as device drivers, compilers, and even whole computer operating systems.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 3rd, 2003, 11:31 AM
|
|
Junior Member
|
|
Join Date: Apr 2003
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
menus
what i need to do is when it asks how many transactions to enter, it will keep coming up until it gets to that number.
then the menu come up. like this.
void display_menu(void)
{
cout << "xxxxxxxxxxxxxxxxxxxxxxx" <<endl;
cout << "x 1. Deposit x" << endl;
cout << "x 2. Withdraw x" << endl;
cout << "x 3. Print Customers x" << endl;
cout << "x 4. Print Transaction x" << endl;
cout << "xxxxxxxxxxxxxxxxxxxxxxx" <<endl;
cin>>cchoice
This is my Problem on this code: when i type in a number it doesnt execute what i want it to do. are these case statements right? also i dont know that to do for #4
switch (cchoice)
{
case 1:
cout << "What is you SSSN? ";
cin << SSN;
cout << "How much would you like to deposit? ";
cin << sDeposit;
break;
case 2:
cout << "What is you SSSN? ";
cin << SSN;
cout << "How much would you like to withdraw? ";
cin << sAccount;
break;
case 3:
cout<<setw(20)<<"Account number"
<<setw(13)<<"Name"
<<setw(9)<<"Balance" << endl;
cout<<setw(20)<<"_________________"
<<setw(13)<<"__________"
<<setw(9)<<"_______"<<endl;
cout<<setw(20)<<sName;
cout<<setw(13)<<AccountNumber
<<setw(9)<<Balance<<endl;
break;
case 4:
break;
}
return 0;
}
This is what needs to happen when they type ina number
1. or 2. Deposit and Withdraw: it will prompt the user for the account # , and amount to enter or withdraw.
3. Print customers: will show all data( account number, names, balance) printed to screen
4. Print transaction: will prompt for a account and then print all of the transactions (type, Amount)
this is the part im stuck on, what to put into the case statements to make 1-4 happen.
|

April 3rd, 2003, 02:32 PM
|
 |
Contributing User
|
|
Join Date: Jan 2003
Location: USA
|
|
Stupid question: Shouldn't the arrows in the input statements point to the right?
For example, you wrote:
Shouldn't it be?:
I've never tried it your way before, so I don't know if it will compile or not. However, that might explain why it's not doing what you expect it to.
Oops! As you were! I was looking at the cases within the switch statement, not at the menu! You did the cin right in the menu, though you still need to correct it in the different cases.
What is the data type of cchoice? If it is not an integer type -- the name suggests char to me -- , then you will need to make it one or else convert it properly or else keep it a char and make your cases for character values (eg, case '1': instead of case 1: ).
As it stands, if cchoice is of type char, then when you enter a '1', its value will be the ASCII value of '1', which is 49. Since none of the switch's cases is for 49, nothing will happen. You should put in a default case (default: ) to trap all other values of cchoice. It should output an error message that includes the value of cchoice received.
Last edited by dwise1_aol : April 3rd, 2003 at 02:36 PM.
|

April 3rd, 2003, 02:33 PM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
First of all, it sounds like you're way over your head on this program, so you either haven't been studying or your teacher has been going way too fast for you.
"What i need to do is when it asks how many transactions to enter, it will keep coming up until it gets to that number"
You might want to consider a for loop.
In a switch statement, each case needs brackets around the body of the code. Check the format of a case statement in your book.
"this is the part im stuck on, what to put into the case statements to make 1-4 happen"
I would create 4 functions that you call depending on what the user chooses. Think of each function as a miniature program to do what you want. Concentrate on one function, code it, and then test it to make sure it works correctly, then move on to the next function.
|

April 3rd, 2003, 04:10 PM
|
 |
not a fan of fascism (n00b)
|
|
Join Date: Feb 2003
Location: ct
|
|
^^ what he said except that case's dont need brackets. 
|

April 3rd, 2003, 10:51 PM
|
|
Contributing User
|
|
Join Date: Feb 2001
Posts: 1,365

Time spent in forums: 18 h 9 m 25 sec
Reputation Power: 14
|
|
|
Yikes! Sorry about that, I don't know what I was looking at.
|

April 5th, 2003, 01:18 PM
|
|
Junior Member
|
|
Join Date: Mar 2003
Posts: 11
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
Have you solve your problem?
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|