Here is the scenario:
Modify your code to check for valid input values. Specifically:
The Wholesale Cost must be positive. { I.e. not zero or negative }
The Mark-up Percentage must be positive but less than or equal to 100%.
The Sales Tax Rate ( Percentage ) must be positive but strictly less than 15%.
Use the most appropriate LOOP construct to get user input until a good value is given.
Be sure your code tells the user that the value entered was wrong, when it is invalid.
If a good value is given, do NOT say anything to the user. I.e. when a good value is given – move on.
Use these input values for each run:
First run should enter all correct values:
Wholesale Cost: $100.00
Mark-up percentage: 8%
Sales tax rate: 3%
Second run
First enter an incorrect value for the wholesale cost – enter a NEGATIVE number,
then enter another incorrect value for the wholesale cost – enter a ZERO,
then enter another incorrect value for the wholesale cost – enter another NEGATIVE number,
then enter a correct wholesale cost of $50.00
Then give a NEGATIVE value for Mark-up percentage
then give a Mark-up percentage value of 200%
then a Mark-up percentage value of 10%
Finally a good value for Sales Tax Rate of 5%.
Third run
First you should enter a correct wholesale cost of $25.00
then a Mark-up percentage value of 100%
then a Sales Tax Rate of -5% ( NEGATIVE 5% )
then a Sales Tax Rate of 0% ( zero )
then a Sales Tax Rate of 15%
then a Sales Tax Rate of 20%
and finally a good value for Sales Tax Rate of 10%.
Here is what I did. I am not sure what I am doing wrong here:
#include <iostream>
#include <iomanip>
using namespace std;
This makes it far easier for someone to quickly look through and analyse your code.
Second thing is...
while (( wholesale_cost being 0 or negative))
What is this supposed to do? As pseudo code to try to plan out your ideas, I can understand, but you are supposed to implement the ( wholesale_cost being 0 or negative) expression.
You might benefit from reading & trying to understand the concepts outlined on the following page:
I am very new to programing so I really do not know what I am suppose to do...do I have to put that while (( wholesale_cost being 0 or negative)) when I am doing the first run? this is what I did now:
// Variable Declarations
int Wholesale_Cost=100;
int Retail_price = 50;
int Customer_Price =25;
int Mark_up_percentage;
int Sales_tax_rate;
while (( wholecost_sale being 0 or negative))
is meaningless in C++.
while (( wholecost_sale <= 0))
has meaning in C++.
while (( int mark_up_percent <=100) && ( int sales_tax_rate < 15))
is incorrect syntax.
while (( mark_up_percent <=100) && ( sales_tax_rate < 15))
is correct syntax.
You have also misunderstood your assignment. 1st run, 2nd run, 3rd run does not mean write 3 different bits of code.
It means write 1 bit of code & run it 3 times, inputting different values each time.