|
heya :D
» who could help me in this C program ? resulting some errors in my codes. |
|
01-02-2010, 01:15 PM
Post: #1
|
|||
|
|||
|
One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Write a macro that will input each salesperson’s gross sales for last week and will calculate and display the salesperson’s earnings. Process one salesperson’s figures at a time. Write out labels for salary, sells, and gross sales to the spreadsheet. Also write the actual values formatted in adjacent cells on the spreadsheet.
thanks
|
|||
|
01-03-2010, 04:40 AM
Post: #2
|
|||
|
|||
|
RE: heya :D
Could you put up your code and the errors?
Guests cannot see links in the messages. Please register to forum by clicking here to see links. |
|||
|
01-03-2010, 08:41 AM
Post: #3
|
|||
|
|||
|
RE: heya :D
here's the codes. please help me check the errors.
#include <stdio.h> #include <conio.h> int main() { int account_number; int beginning_balance; int total_charges; int total_credits; int credit_limit; int balance; int counter; /* intialization phase */ total_charges = 0; total_credits = 0; account_number = 0; beginning_balance = 0; counter = 0; balance = 0; credit_limit = 0; while (account_number != -1) { printf("Enter account number ( -1 to end ):"); scanf("%.2f", &account_number); if ( account_number != -1 ) { printf("Enter beginning balance:\n"); scanf("%.2f", &beginning_balance); printf("Enter total charges\n"); scanf("%.2f", &total_charges); printf("Enter total credits:\n"); scanf("%.2f", &total_credits ); printf("Enter credit limit:\n"); scanf("%.2f", &credit_limit); } if (balance > credit_limit) { balance = beginning_balance + total_charges - total_credits; printf ("Account: %.2f", account_number); printf ("Credit limit: %.2f", credit_limit); printf ("Balance: %.2f", balance); printf ("Credit limit exceeded\n"); } getch (); } } |
|||
|
01-03-2010, 06:22 PM
Post: #4
|
|||
|
|||
|
RE: heya :D
Shouldn't you be using floats?
Check our cin and cout tutorial. Unless you HAVE to use C and not C++. ![]() ☤ ☢ Software Engineer - Director of Inferno ☢ ☤ |
|||
|
01-04-2010, 08:28 AM
Post: #5
|
|||
|
|||
|
RE: heya :D
i am using C not C++.
|
|||
|
01-04-2010, 11:13 PM
Post: #6
|
|||
|
|||
|
RE: heya :D
when you use %.2f in printf/scanf this means its expecting a float number but your variables are integers, either change your variable type to float or use %d in your printf/scanf commands
|
|||
|
01-05-2010, 08:57 PM
Post: #7
|
|||
|
|||
|
RE: heya :D
yes, exactly what sh0x is saying.
Also tell me if you get any ERRORS, post them. And please wrap your code with [code = cpp] without spaces and [/code] in order to highlight it properly. ![]() ☤ ☢ Software Engineer - Director of Inferno ☢ ☤ |
|||
|
« Next Oldest | Next Newest »
|







![[Image: adminexecuterh8.png]](http://img159.imageshack.us/img159/526/adminexecuterh8.png)