I am new at C++ programming..Anyway I need to create a C++ Program that involves one large chemical company that pays its salepeople on a commission basis. The sale people receive $200 per week plus 9 per cent of their gross sale for that week. For example,a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9 percent of $5000, or a total of $650. Develop a C++ program that uses a while structure to imput each salesperson's gross sales last week and calculate and display that salesperson's earnings. Process one salesperson's figure at a time.

Can any help me..
Thanks Jessie

We can help you, but first you have to help yourself. Try to solve the problem first and when you get stuck, ask a question; we won't do your homework for you. If you get stuck with designing your solution, at least post some pseudocode. If your code isn't doing what you think it should, post it and we'll look it over.

Okay This is what I came up with.But when I preform the task I enter
Enter sales in dollars (-1 to end): I put 5000.00
then it answers $650.00 over and over in a insane repeat


# include <iostream>

using std::cin;
using std::cout;
using std::endl;
using std::fixed;

# include <iomanip> // parameterized stream manipulaters

using std::setprecision; // sets numeric output precision

// function main begins program execution
int main ()

{
int base;
int sales;
int salary;

double commission;

base = 200;
commission = .09;

while ( sales != -1 ) {
cout << "enter sales, -1 to end :";
cin >> sales;

salary= static_cast< double >( commission * sales ) + base;
cout << "salary is $" << salary << endl;
}

if ( sales == -1 ) {
cout << "Program ends\n";
}


return 0; // indicate that program ended successfuly
}

1) use code tags when you post code please. It preserves formatting and makes it easier to read.

2) When I ran it, it seemed to work fine.

3) couple notes about your code:

int base;  
  int sales;
  int salary;
  double commission;
 
  base = 200; // should just initialize variables
  commission = .09; // should just initialize variables
 
  while ( sales != -1 ) { //sales not yet initialized, I get a compiler warning
    cout << "enter sales, -1 to end :";
    cin >> sales;
    //static_cast should just be around sales, rather than (commission*sales) (also get a warning related to this)
    salary= static_cast< double >( commission * sales ) + base;
    cout << "salary is $" << salary << endl;
  }

Why dont you declare each and every variable as double, that way you can do away with the cast. Also initialize the var at declaration to avoid confusion and using the values before they are defined.

Thanks everyone for your help and information

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.