Re: Homework Function Help.
C++ is case sensitive.
Pay attention to the direction when using << and >>.
Use whitespace for improved readability.
Re: Homework Function Help.
So I messed up on << and >>? Was that the only thing?
Re: Homework Function Help.
Quote:
Originally Posted by
Poeticsoul44
So I messed up on << and >>? Was that the only thing?
I don't do a lot of console programming, but I'm not sure sending endl to cin makes any sense.
I also mentioned that C++ is case sensitive.
Re: Homework Function Help.
Yea. I caught the error..But theres something else wrong with it because they wont compile for some reason.
Re: Homework Function Help.
Quote:
Originally Posted by
Poeticsoul44
Yea. I caught the error..But theres something else wrong with it because they wont compile for some reason.
There are lots of errors. I already pointed out the category. What does the compiler say?
Re: Homework Function Help.
the first gives the following errors:
air.cpp: In function âvoid airfare(double&, double&)â:
air.cpp:3: error: âcoutâ was not declared in this scope
air.cpp:3: error: âendlâ was not declared in this scope
air.cpp:4: error: âcinâ was not declared in this scope
air.cpp:5: error: âairefareAllowedâ was not declared in this scope
air.cpp:5: error: âairefareCostâ was not declared in this scope
The second funtion i get these errors:
miles.cpp: In function âvoid milage(int, double&, double&)â:
miles.cpp:3: error: âcoutâ was not declared in this scope
miles.cpp:3: error: âendlâ was not declared in this scope
miles.cpp:4: error: âcinâ was not declared in this scope
And the third gives me these errors:
taxi.cpp: In function âvoid taxi(int, double&, double&)â:
taxi.cpp:3: error: âcoutâ was not declared in this scope
taxi.cpp:3: error: âendlâ was not declared in this scope
taxi.cpp:4: error: âcinâ was not declared in this scope
[wm136158@adanew ~]$
Re: Homework Function Help.
Did you include iostream?
Re: Homework Function Help.
I just did and i get these errors for the first:
air.cpp: In function âvoid airfare(double&, double&)â:
air.cpp:4: error: âcoutâ was not declared in this scope
air.cpp:4: error: âendlâ was not declared in this scope
air.cpp:5: error: âcinâ was not declared in this scope
air.cpp:6: error: âairefareAllowedâ was not declared in this scope
air.cpp:6: error: âairefareCostâ was not declared in this scope
For the second i get:
miles.cpp: In function âvoid milage(int, double&, double&)â:
miles.cpp:4: error: âcoutâ was not declared in this scope
miles.cpp:4: error: âendlâ was not declared in this scope
miles.cpp:5: error: âcinâ was not declared in this scope
and the third i get:
taxi.cpp: In function âvoid taxi(int, double&, double&)â:
taxi.cpp:4: error: âcoutâ was not declared in this scope
taxi.cpp:4: error: âendlâ was not declared in this scope
taxi.cpp:5: error: âcinâ was not declared in this scope
Re: Homework Function Help.
Post your entire code as it is now.
Re: Homework Function Help.
First function code:
#include <iostream>
void airfare(double &airfareCost, double & airfareAllowed)
{
cout<< "Enter cost of airfare"<<endl;
cin>>airfareCost;
airefareAllowed=airefareCost;
}
2nd:
#include <iostream>
void milage(int miles,double &milageCost, double&milageAllowed)
{
cout<<"Enter cost of milage"<<endl;
cin>>milageCost;
cout<<"enter number of mile"<<endl;
cin>>miles;
milageAllowed= miles * 0.38;
}
3rd:
#include <iostream>
void taxi(int taxiDays, double &taxiCost, double&taxiAllowed)
{
cout<< "Enter number of days travelled"<<endl;
cin>>taxiDays;
cout<<"enter total cost of taxi"<<endl;
cin>>taxiCost;
taxiAllowed=taxiDays *10;
}
Re: Homework Function Help.
You forgot to put
Code:
using namespace std;
at the top.
And there's no need to #include a file more than once in a given cpp.
Re: Homework Function Help.
I just included "using namespace std;" and get these errors:
1st:
air.cpp: In function âvoid airfare(double&, double&)â:
air.cpp:7: error: âairefareAllowedâ was not declared in this scope
air.cpp:7: error: âairefareCostâ was not declared in this scope
2nd:
miles.cpp: In function âvoid milage(int, double&, double&)â:
miles.cpp:4: error: âcoutâ was not declared in this scope
miles.cpp:4: error: âendlâ was not declared in this scope
miles.cpp:5: error: âcinâ was not declared in this scope
3rd:
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../lib64/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status
Re: Homework Function Help.
You're going to have to give us more to work with if you want help sorting this out.....
Re: Homework Function Help.
What all do you want to know?