Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

need help with showing the negatives in my C++ program

Computer Science
I got my questions answered at in under 10 minutes. Go to now for free help!
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer


To see the expert answer you'll need to create a free account at Brainly

here is the question Your program will continue asking for the sales until the user types a negative number for sales, then the program should ask the user, if he/she wants to terminate the program. The program terminates if the user answers yes or y.
I'm not quite sure on C++ syntax, but you need a loop that looks like this: int number; do{ ask value of number from input }while (number >= 0); //This loop will repeat until number is -1 or smaller As for the second part, what happens if the user doesn't want to terminate the program, it starts over?
this is what i have so far it runs just cant get it to ask for termination #include #include using namespace std; double CalcCommision (double &sale) { double commission; if(sale <=999) commission= sale * .035; //This equation calculate commission that is 3.5% of sales between $0 and $999 else if(sale >= 1000 <=1999) commission= sale * .040; //This equation calculates commission that is 4% of sales between $1000 and $1999 else if(sale >= 2000 <=2999) commission= sale * .045; //This equation calculates commission that is 4.5% of sales between $2000 and $2999 else if (sale <=3000) commission= sale * .050; //This equation calculates commission that is 5% of sales $3000 or greater return commission; } int main() { string yes; double sale; sale = 0; // initialize sale cout << "5000" <> sale; while (true) //the while statement starts loop, while statement is being utilized if a positive number is entered //once an ammount is entered, the commission value returned to main module is displayed with CalcCommission {if(sale>=0) {cout << endl; cout << endl; cout << endl; cout << endl; cout << "1000: $" << sale << ".040: $" << CalcCommision (sale) << endl; } else // if a negative number is entered, program jumps here to ask user if they would like to terminate the program { cout << endl; cout << endl; cout<< endl; cout << "y"; cin>>yes; if("yes")==0| } cout << "1999: $ "; cin >> sale; } }

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

There's two ways to solve this. 1. You can put everything in your main() function inside a big do-while, with the "yes/y" condition at the end, where you exit the cycle if the user has typed yes or y. 2. Inside an if{ } you can use exit(0), where 0 indicates the status in which the process terminates (0 = normally, no errors). This will end your program.

Not the answer you are looking for?

Search for more explanations.

Ask your own question