Hi. I am working on my final project for class and I'm having trouble with the equation. For some reason, my numbers will not calculate correctly when entered. Can someone please help me? The code is pretty long because it is my first ever project. I am using Visual Studio 2019 for this project. Thanks.
Example: I ask the user for the weight of the dog. They enter 75.
Then I ask the user for miles needed to be traveled. They enter 150.
Since the miles are 150, the rate is $3.00.
shipping_Cost = (miles * rates) + (weight * 3).
For the information giving above, I'm getting $375 when I need to get $675.
{
string name;
cout << "Please enter your name: ";
getline(cin, name);
cout << "Hello " << name << ", Welcome to James' Dog Shipping Calculator!!\n";
int choice,
miles,
weight,
rates{};
char healthCertificate,
overWeight;
cout << "Please answer the following questions.\n";
cout << "Use Y for Yes and N for No.\n";
cout << "Is your dog under 75lbs? ";
cin >> overWeight;
cout << "Do you have an updated Health Certificate? ";
cin >> healthCertificate;
if (overWeight == 'Y')
{
if (healthCertificate == 'Y')
{
cout << "You may continue to the next step.\n";
}
else
{
cout << "You must have an updated Health Certificate ";
cout << "for us to ship your dog.\n";
}
}
else
{
cout << "Your dog must be under 75lbs to ship.\n";
cout << "\t\tDog Group Menu\n\n"
<< "1. Toy Breed Group\n"
<< "2. Terrier Group\n"
<< "3. Non-Sporting Group\n"
<< "4. Quit the program\n\n"
<< "Enter your choice: ";
cin >> choice;
if (choice == TOY_CHOICE)
{
cout << "How much does your dog weigh? ";
cin >> weight;
while (weight > 75)
{
cout << "Your dog must be under 75lbs to ship. \n";
cout << "How much does your dog weigh? ";
cin >> weight;
}
cout << "Please enter the amount of miles from pickup city to destinated city:";
cin >> miles;
if (miles <= 150){
rates = 3.00;
shipping_Cost = (miles * rates) + (weight * 3);
}
if (miles <= 200){
rates = 2.50;
shipping_Cost = (miles * rates) + (weight * 3);
}
if (miles <= 250){
rates = 2.25;
shipping_Cost = (miles * rates) + (weight * 3);
}
if (miles <= 300){
rates = 2.00;
shipping_Cost = (miles * rates) + (weight * 3);
}
if (miles <= 399){
rates = 1.75;
shipping_Cost = (miles * rates) + (weight * 3);
}
if (miles >= 400){
rates = 1.50;
shipping_Cost = (miles * rates) + (weight * 3);
}
cout << "Your shipping charge will be $" << shipping_Cost << " for this trip." << endl;
}
else if (choice == TERRIER_CHOICE)
{
cout << "How much does your dog weigh?";
cin >> weight;
while (weight > 75)
{
cout << "Your dog must be under 75lbs to ship. \n";
cout << "How much does your dog weigh? ";
cin >> weight;
}
cout << "Please enter the amount of miles from pickup city to destinated city:";
cin >> miles;
if (miles <= 150){
rates = 3.00;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 200){
rates = 2.50;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 250){
rates = 2.25;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 300){
rates = 2.00;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 399){
rates = 1.75;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles >= 400){
rates = 1.50;
shipping_Cost = (miles * rates) + (weight * 2);
}
cout << "Your shipping charge will be $" << shipping_Cost << " for this trip." << endl;
}
else if (choice == NONSPORT_CHOICE)
{
cout << "How much does your dog weigh?";
cin >> weight;
while (weight > 75)
{
cout << "Your dog must be under 75lbs to ship. \n";
cout << "How much does your dog weigh? ";
cin >> weight;
}
cout << "Please enter the amount of miles from pickup city to destinated city:";
cin >> miles;
if (miles <= 150){
rates = 3.00;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 200){
rates = 2.50;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 250){
rates = 2.25;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 300){
rates = 2.00;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles <= 399){
rates = 1.75;
shipping_Cost = (miles * rates) + (weight * 2);
}
if (miles >= 400){
rates = 1.50;
shipping_Cost = (miles * rates) + (weight * 2);
}
cout << "Your shipping charge will be $" << shipping_Cost << " for this trip." << endl;
}
else if (choice == QUIT_CHOICE)
{
cout << "Program is ending.\n";
}
return 0;
}