lundi 22 mars 2021

"Code will never be executed" error on lines 51. 53. and 55. What can I do to remove this error?

int main() {

double weight;
double weight_CHARGE;
double distance_CHARGE;
double total_CHARGE;
int distance;

cout << "Welcome to Luke's Shipping Company!\n" << endl;
cout << "Please enter the weight in pounds of your package:\n " << endl;
cin >> weight;

while(weight < 0 || weight > 20)
{
    cout << "\nERROR! Weight over 20 pounds is an invalid input.";
    cout << "Please enter a new value: ";
    cin >> weight;
}
if (weight >= 0 || weight <= 10)
    weight_CHARGE = weight * 0.75;
else if(weight >= 10 || weight <= 15)
    weight_CHARGE = weight * 0.85;
else if (weight >= 15 || weight <= 20)
    weight_CHARGE = weight * 0.95;

cout << "Please enter the distance in miles to be shipped:\n ";
cin >> distance;

while(distance < 0 || distance > 500)
{
    cout << "\nERROR! Distance over 500 miles is an invalid input.";
    cout << "Please enter a new value:  ";
    cin >> distance;
}


if(distance >= 0 || distance <= 50)
    distance_CHARGE = distance * 0.07;
else if (distance >=50 || distance <= 100) // line 51
    distance_CHARGE = distance * 0.06;
else if (distance >= 100 || distance <= 200) // line 53
    distance_CHARGE = distance * 0.05;
else if (distance >= 200 | distance <= 500) // line 55
    distance_CHARGE = distance * 0.04;

return 0;

}

**// this program wants me to calculate total charge based on inputted distance and weight. The while loops are for user input validation. I just keep running into a problem of a "code will never execute" error.

Aucun commentaire:

Enregistrer un commentaire