![]() |
|
|||||||
|
|
Thread Tools | Search this Thread | Rate Thread |
|
#1
|
|||
|
|||
Minor Problem with my program. Any help greatly appreciated.Hi. I'm trying to make a program where the program asks for:
1. customer number 2. 1st letter of customer's last name 3. Amount This is what I have so far: CPP / C++ / C Code:
The only problem I have is that I want this program to keep asking the user those 3 questions until the user enters zero for the customer number. Like this: Screen: customer number?: 12 1st letter of customer's last name?: W Amount?: 99.95 Customer number?:0 If anyone could give me some advice as to what I can do, I would greatly appreciate it. Thanks! :-D P.S. - Does anybody know how to print out ammount in dollars and cents? ($1.50) |
|
#2
|
|||
|
|||
|
Use a do while loop whith choice >0
CPP / C++ / C Code:
Also if you just want to print dollar sign then use "$" sign in your printf statment.For e.g. CPP / C++ / C Code:
|
|
#3
|
||||
|
||||
|
Quote:
While your first suggetion works, your second is somewhat off. Isn't amount a floating point number? How does %d output a floating point value with 2 decimals? A correct answer is %.2f for your format string. This prints the number with 2 decimals. __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#4
|
|||
|
|||
|
Quote:
i do not know to ask my question in here is right or not but it is related to this situation if it is wrong pls warn me!!! in c we use %.2f but i want to implement in c++ in cout what is its format??? |
|
#5
|
|||
|
|||
|
Hi Waltp,
It was a general example and not as per the code in first post. :-) |
|
#6
|
||||
|
||||
|
Quote:
I have no probelm with "general" answers (I perfer them myself) but make sure you write the response with no question that it's an idea of what to do, not an example of what will work. Avoids confusion... __________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#7
|
|||
|
|||
|
Aye Aye.. :-)
|
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 14:30 |
| Anyone can write a program code for this??? | chriskan76 | C Programming Language | 1 | 19-Oct-2004 21:25 |
| Need help with a C program (Long) | McFury | C Programming Language | 3 | 29-Apr-2004 21:06 |
| error during program | rjd72285 | C++ Forum | 0 | 11-Nov-2003 19:49 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The