Thread: [Dev-C++] Newbie: Error in IOSTREAM declaration
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Opacki, J. <Jos...@ng...> - 2003-09-29 15:43:24
|
I'm new to this, can someone help we pinpoint the error?
Thanks...Joe
***ERROR***
2 C:\compile\compile.cpp:3 invalid preprocessing directive
#inlcude
***CODE***
// program to compute bill for either a wholesale or retail purchase
#include <iostream>
#inlcude <cstdlib>
using namespace std;
const double TAX_RATE = 0.05; // 5% sales tax
int main()
{
char salesType, ans;
int number;
double price, total;
do
{
cout << "Enter price $";
cin >> price;
cout << "Enter number purchased: ";
cin >> number;
cout << "Type W if this a wholesale purchase.\n"
<< "Type R if this a retail purchase.\n"
<< "Then press Return.\n";
cin >> salesType;
if ( (salesType == 'W') || (salesType == 'w') )
{
total = price * number;
} else if ( (salesType == 'R') || (salesType == 'r') )
{
double subtotal;
subtotal = price * number;
total = subtotal + subtotal * TAX_RATE;
} else
{
cout << "Error in input" << endl;
}
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << number << "items at $" << price << endl;
cout << "Total Bill = $" << total;
if ( (salesType == 'R') || (salesType == 'r') )
{
cout << " including sales tax.\n";
}
cout << endl << "Would you like to try again (Y or N)? ";
cin >> ans;
cout << endl;
} while (ans == 'y' || ans == 'Y');
system("pause");
return 0;
}
|
|
From: David M. <ci...@ya...> - 2003-09-29 16:14:33
|
You spelled "include" wrong on line 2 for #include
<cstdlib>
The compiler is EXTREMLY picky when it comes to spelling. A
easy way to pick out errors is to look at the line number
(in this case 2) of the error. That usually pinpoints what
statement is causing the error. The most notable exception
to this rule is forgetting a semi-colon when you do the
error is reported as coming from the next statement.
Happy Coding
David McKen
--- "Opacki, Joseph" <Jos...@ng...> wrote:
> I'm new to this, can someone help we pinpoint the error?
>
> Thanks...Joe
>
> ***ERROR***
> 2 C:\compile\compile.cpp:3 invalid preprocessing
> directive
> #inlcude
>
> ***CODE***
> // program to compute bill for either a wholesale or
> retail purchase
> #include <iostream>
> #inlcude <cstdlib>
>
> using namespace std;
>
> const double TAX_RATE = 0.05; // 5% sales tax
>
> int main()
> {
> char salesType, ans;
> int number;
> double price, total;
>
> do
> {
> cout << "Enter price $";
> cin >> price;
> cout << "Enter number purchased: ";
> cin >> number;
> cout << "Type W if this a wholesale purchase.\n"
> << "Type R if this a retail purchase.\n"
> << "Then press Return.\n";
> cin >> salesType;
>
> if ( (salesType == 'W') || (salesType == 'w') )
> {
> total = price * number;
> } else if ( (salesType == 'R') || (salesType ==
> 'r') )
> {
> double subtotal;
> subtotal = price * number;
> total = subtotal + subtotal * TAX_RATE;
> } else
> {
> cout << "Error in input" << endl;
> }
>
> cout.setf(ios::fixed);
> cout.setf(ios::showpoint);
> cout.precision(2);
>
> cout << number << "items at $" << price << endl;
> cout << "Total Bill = $" << total;
>
> if ( (salesType == 'R') || (salesType == 'r') )
> {
> cout << " including sales tax.\n";
> }
>
> cout << endl << "Would you like to try again (Y
> or N)? ";
> cin >> ans;
> cout << endl;
> } while (ans == 'y' || ans == 'Y');
>
>
> system("pause");
> return 0;
> }
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE:
> http://www23.brinkster.com/noicys/devcpp/ub.htm
>
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
=====
Signed
David Mcken
Life Sucks
Live with it
__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com
|
|
From: Per W. <pw...@ia...> - 2003-09-29 16:20:13
|
How do you spell the reserved word 'include'?
Exactly what the compiler said: it didn't recognized the word immediately
after the hash character.
/Per W
On Mon, 29 Sep 2003, Opacki, Joseph wrote:
> I'm new to this, can someone help we pinpoint the error?
>
> Thanks...Joe
>
> ***ERROR***
> 2 C:\compile\compile.cpp:3 invalid preprocessing directive
> #inlcude
>
> ***CODE***
> // program to compute bill for either a wholesale or retail purchase
> #include <iostream>
> #inlcude <cstdlib>
>
> using namespace std;
>
> const double TAX_RATE = 0.05; // 5% sales tax
>
> int main()
> {
> char salesType, ans;
> int number;
> double price, total;
>
> do
> {
> cout << "Enter price $";
> cin >> price;
> cout << "Enter number purchased: ";
> cin >> number;
> cout << "Type W if this a wholesale purchase.\n"
> << "Type R if this a retail purchase.\n"
> << "Then press Return.\n";
> cin >> salesType;
>
> if ( (salesType == 'W') || (salesType == 'w') )
> {
> total = price * number;
> } else if ( (salesType == 'R') || (salesType == 'r') )
> {
> double subtotal;
> subtotal = price * number;
> total = subtotal + subtotal * TAX_RATE;
> } else
> {
> cout << "Error in input" << endl;
> }
>
> cout.setf(ios::fixed);
> cout.setf(ios::showpoint);
> cout.precision(2);
>
> cout << number << "items at $" << price << endl;
> cout << "Total Bill = $" << total;
>
> if ( (salesType == 'R') || (salesType == 'r') )
> {
> cout << " including sales tax.\n";
> }
>
> cout << endl << "Would you like to try again (Y or N)? ";
> cin >> ans;
> cout << endl;
> } while (ans == 'y' || ans == 'Y');
>
>
> system("pause");
> return 0;
> }
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Ricardo_Lopez <ri...@un...> - 2003-09-29 16:22:15
|
#inlcude <cstdlib> INCLUDE |