C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 3rd, 2003, 11:31 AM
Jill24 Jill24 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 1 Jill24 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question 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.

Reply With Quote
  #2  
Old April 3rd, 2003, 02:32 PM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed God 2nd Plane (6000 - 6499 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 6,127 dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level)dwise1_aol User rank is General 14th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 2 Weeks 3 Days 18 h 16 sec
Reputation Power: 1949
Stupid question: Shouldn't the arrows in the input statements point to the right?

For example, you wrote:
Code:
cin << sDeposit;

Shouldn't it be?:
Code:
cin >> sDeposit;


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.

Reply With Quote
  #3  
Old April 3rd, 2003, 02:33 PM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,365 7stud User rank is Private First Class (20 - 50 Reputation Level)7stud User rank is Private First Class (20 - 50 Reputation Level) 
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.

Reply With Quote
  #4  
Old April 3rd, 2003, 04:10 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
^^ what he said except that case's dont need brackets.

Reply With Quote
  #5  
Old April 3rd, 2003, 10:51 PM
7stud 7stud is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Feb 2001
Posts: 1,365 7stud User rank is Private First Class (20 - 50 Reputation Level)7stud User rank is Private First Class (20 - 50 Reputation Level) 
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.

Reply With Quote
  #6  
Old April 5th, 2003, 01:18 PM
Doctor - A Doctor - A is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 11 Doctor - A User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Have you solve your problem?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > menus

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap