Hello, I am just starting out and need some advice on a code I am working on.
The code works but I cant figure out how to do one thing. That is to get it to calculate in increments of 500 miles. Any help is appreciated thanks.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float rate = 0, weight = 0, miles = 0, shipping = 0, cost = 0;
yes, you're correct. This code works. But it works not like you want it to work :) There's a bug.
Instead of elseif (weight > 2 || weight <= 6)
should be elseif (weight > 2 && weight <= 6).
Another thing is that you could skip first checks in ifs.
Instead of elseif (weight > 2 || weight <= 6)
can be elseif( weight <= 6). In other ifs too.
And about your main question. Imo this code works correct (after earlier changes).
Can you specify your question? What is the result and what result you expect?
Thanks for the reply and also thanks for reminding me to change the || to &&.
The main question is that say the user inputs the weight of 4 and a distance of 700.
it should calculate the shipping in increments of 500. it would be 2.20 * 2. Total shipping would be 4.40