Join 136,926 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,823 people online right now. Registration is fast and FREE... Join Now!
using c++ develop a program for the ABC company whose salespeople are paid both a base salary and a commission. Input to the program is sales person's first and last names and weekly sales. Output is the salesperson's first initial, and full last name and correct pay. Pay is calculated as follows. Each salesperson receives a base pay of $300.00 as well as a 10% commission on sales up to and including $500.00. Any portion of sales over 500 merits a 15% commission for the employee
Not too bad but remember that you must ask for information before you can go using it in calculations. You can't use sales variable before you asked the user for it. So I switched the input and the calculations around.
Keep in mind (like mentioned in the in-code comments) that the 15% only applies to the dollars over the 500 mark. You get 10% on the first 500 and anything over 500 is at 15%. Not 15% of the total sales amount.
// Prompt for the data first from the user before attempting // to use variables like "sales" in calculations. // How can you use sales when you hadn't asked for it yet? std::cout<< "Please Enter First and Last Name"<<std::endl; std::cin>>fName>>lName; std::cout<< "Enter Sales"<<std::endl; std::cin>>sales;
// Good start, but remember the 15% applies to any // value OVER the initial 500, not the total sales. // eg 600 in sales is 10% of 500 or $50 but then 15% of 100 // (600 - 500 = 100 which is what part is over 500). // answer: 300 base + 50 (10% of 500) + 15 (15% of 100 over 500) = $365.00 bpay= 300.00; com1= sales * .10; com2= sales * .15; tpay= (bpay+com1); tpay2= (bpay+com2);
// Fixed up your curly braces here. // It is good practice to always include curly braces. if (sales <= 500) { std::cout << fName[0] << " " << lName << std::endl; std::cout << tpay << std::endl; }
If you mean that the program simply ends, try holding open the window using something like getchar() at the end. It might be doing your calculation real fast and closing the program.
If you mean that the program simply ends, try holding open the window using something like getchar() at the end. It might be doing your calculation real fast and closing the program.
You can't be too confused, you are on the right track. Just remember that if the sales is less than 500, you apply 10% to it. If it is greater than 500 you apply 10% to the 500 and then 15% to the total sales minus the 500.
You can't be too confused, you are on the right track. Just remember that if the sales is less than 500, you apply 10% to it. If it is greater than 500 you apply 10% to the 500 and then 15% to the total sales minus the 500.
The getchar() at the end before the return 0 should pause your program (waiting for input) and thus should not close. Make sure you are also running the program in a debug mode which may help keep it open.
I have seen other people ask about it in Bloodshed Dev and that is what they are using is the getchar().
If that doesn't work, you could try system("pause"); which should work if you are on a windows machine.