I found a lot of my mistakes from the guidance of a friend and looking more carefully, but I am still getting an error message for something I see nothing wrong with. The last else statement has two errors I don't know how to fix, and "int main()".
CODE
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
main()
{
float a, b, c, d;
cout << "What was last month's reading?" << endl;
cin >> a;
cout << "What is this month's reading?" << endl;
cin >> b;
c = 1000 - a + b;
if (c <= 70) {d == 5;
}
else if (70 <= c && c <= 170)
{
d == ((c - 70) * .05) + 5;
}
else if (170 <= c && c <= 400)
{
d == ((c - 170) * .025) + 10;
}
else (c => 400) {d == ((c - 400) * .015) + 15.75;
}
cout << "Last Month's Reading: "<<a<<" cubic metres.\n";
cout << "This Month's Reading: "<<b<<" cubic metres.\n";
cout << "Gas Used: "<<c<<" cubic metres.\n";
cout << "Total Charges: "<<d<< "dollars.\n";
system ("pause");
}
Original Post:
I'm pretty much lost on what to do. It tells me it is expecting primary-expression. I saw another thread on it, but when I tried the suggested solution, it didn't work. It also tells me some numbers cannot be used as a function... But I don't know what that means.
CODE
#include<iostream>
#include<cstdlib>
using namespace std;
main()
{
float a, b, c, d;
cout << "What was last month's reading?" << endl;
cin >> a;
cout << "What is this month's reading?" << endl;
cin >> b;
c = 1000 - a + b;
if (c <= 70) {d == 5();
}
else if (70 <= c <= 170) {d = ((c - 70) * .05) + 5();
}
else if (170 <= c <= 400) {d = ((c - 170) * .025) + 10();
}
else (c => 400) {d = ((c - 400) * .015) + 15.75();
}
cout << "Last Month's Reading: "<<a<<" cubic metres.\n";
cout << "This Month's Reading: "<<b<<" cubic metres.\n";
cout << "Gas Used: "<<c<<" cubic metres.\n";
cout << "Total Charges: "<<d<< "dollars.\n";
system ("pause");
}
This post has been edited by Tanooki: 5 Sep, 2007 - 07:56 AM