I am writing a program that is needing input validation saying that if the units are less than or equal to 0 the program won't run, but I keep getting the string with the total included but I am not trying to run that if the value is 0.
//Write a program that asks for the numbers of units sold and computes the total cost of purchase
//Make sure to use input validation that the number of units is greater than 0
#include <iostream>
using namespace std;
int main ()
{
double discount, discountTotal, units, total;
double package = 99;
cout << "What is the number of units sold? ";
cin >> units;
if(units <=0){
cout << "Units must be greater than 0" << endl;
}
if(units > 0 && units < 10)
discount = .00;
else if(units >=10 && units <= 19)
discount = .20;
else if(units >=20 && units <= 49)
discount = .30;
else if(units >=50 && units <= 99)
discount = .40;
else if(units >=100, .50)
discount = .50;
discountTotal = package * discount;
total = package - discountTotal;
cout << "Your total is: " << total << endl;
return 0;
}