repost

expression syntax error occured on this program.. can someone tell me what's my mistake on this one? again some advice please.. :)

// this program display the price for shipping company
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
float weight, distance, price;

cout << " tell me your weight package";
cin >> weight;

if (weight > 0 && weight < 20)
{

cout << "sorry, this package is not available\n";
cout << "please try again later ";
}
else
{
cout << "okay, now please tell me how far it will travel(distance)";
cin >> distance;


[if (weight<2) && (distance>10 && distance<3000) ] **problem occured here
{
price = distance*(1.10/500)
}
else if (weight>=2 || weight < 6) && (distance >10 && distance < 3000)
{
price = distance*(2.20/500)
}
else if (weight>=6 || weight < 10) && (distance>10 && distance < 3000)
{
price = distance*(3.70/500);
}
else if weight >=10 || weight< 20) && (distance>10 && distance < 3000)
{
price = diatance*(4.80/500)
}

cout << " okay sir, all you need to pay is RM" << fixed << setprecision(2) << price << endl;
}

return 0;
}
[if (weight<2) && (distance>10 && distance<3000) ] **problem occured here

You need forgot the main braces for the if
The "if ( )" statement is ended at the first close parenthesis; the rest of the line is a syntax error as written.

Suggestion: if ( ( condition1 && condition2 ) || (condition3 && condition4) )

There are several other logical expression errors as well. Remember - "=" is assignment, "==" is comparison.

Another suggestion: Use the Format: <> button to insert your code into a code tag; makes it easier to point you to a location in your code by line number.
Topic archived. No new replies allowed.