-
Homework help =)
I get 2 errors in this cant find um some1 help =/
just started learning c++ in class and this is due in about a week
// File tax.cpp
// Description: cost calculator
// Programmer: Chris
// Date: 2/8/06
#include <iostream>
using namespace std;
const fuel = .005;
const tax = .0865;
const int airport = 15;
const double discount = .13 endl;
int main()
{
int tickets;
double ticketprice, tickettotal, subtotal, fuelsurcharge, discount,
fuelcharge;
double withoutfuel, withfuel, disamount, taxamount, totaldue, Airport,
Total;
cout << "Enter the number of tickets.";
cin >> tickets
cout << "Enter the price for each ticket.";
cin >> ticketprice;
cout << endl;
tickettotal = tickets * ticketprice;
discount = tickettotal * discount;
withoutfuel = tickettotal - discount;
fuelcharge = fuel * withoutfuel;
withfuel = withoutfuel + fuelsurcharge;
taxamount = tax * withfuel;
totaldue = withfuel + taxamount + airport;
cout << "Subtotal = " << tickettotal << endl;
cout << "Amount of discount = " << disamount << endl;
cout << "Total without fuel surcharge = "<< withoutfuel << endl;
cout << "Fuel surcharge = " << fuelsurcharge << endl;
cout << "Total with fuel surcharge = " << withfuel << endl;
cout << "Tax = " << taxamount << endl;
cout << "Airport charge is $ " << Airport << endl;
cout << Total = " << totaldue << endl;
return 0;
}
-
And how long have you had it :P?
You could always ask your teacher/lecturer for help.
-
lol today just now like 3 hours ago but im lost as to what causes errors i went over it 10 times with class notes lol >.< its ok il learn just was hopeing some1 would take a swing at it its probobly a noobish error...
-
cin >> tickets
you forgot the ending ';' -> should be 'cin >> tickets;'
cout << Total = " << totaldue << endl;
you forgot the first '"' -> should be 'cout << "Total = " << totaldue << endl;'
I don't have Dev-Cpp installed at the moment (my normal C++ IDE) so can't run it myself, but if this doesn't fix it, tell me what the errors say. Ultimately, use a debugger.
-
Code:
// File tax.cpp
// Description: cost calculator
// Programmer: Chris
// Date: 2/8/06
#include <iostream>
using namespace std;
const fuel = .005;
const tax = .0865; Define what type are they, Float or Double (I think you must)
const int airport = 15;
const double discount = .13 endl;
int main()
{
int tickets;
double ticketprice, tickettotal, subtotal, fuelsurcharge, discount,
fuelcharge;
double withoutfuel, withfuel, disamount, taxamount, totaldue, Airport,
Total;
cout << "Enter the number of tickets.";
cin >> tickets Add an ";" here
cout << "Enter the price for each ticket.";
cin >> ticketprice;
cout << endl;
tickettotal = tickets * ticketprice;
discount = tickettotal * discount;
withoutfuel = tickettotal - discount;
fuelcharge = fuel * withoutfuel;
withfuel = withoutfuel + fuelsurcharge;
taxamount = tax * withfuel;
totaldue = withfuel + taxamount + airport;
cout << "Subtotal = " << tickettotal << endl;
cout << "Amount of discount = " << disamount << endl;
cout << "Total without fuel surcharge = "<< withoutfuel << endl;
cout << "Fuel surcharge = " << fuelsurcharge << endl;
cout << "Total with fuel surcharge = " << withfuel << endl;
cout << "Tax = " << taxamount << endl;
cout << "Airport charge is $ " << Airport << endl;
cout << Total = " << totaldue << endl; Add infront of Total an ", you forgot it.
return 0;
}
ps: why int main() and not just void main()? :)
pss: some of the vars you use, set them to "0", cuz some times they have "forgoten" value inside and they will give you wrong output / calculations :)
-
How would i set them to 0 yea cause they do come out all screwy
=/
-
Simple...
when you declare it. GL ;)
-
At this point of the prog, where you define the vars and the type of em.
Code:
int tickets = 0;
double ticketprice = 0, tickettotal = 0, subtotal = 0, fuelsurcharge = 0, discount = 0,
fuelcharge = 0;
double withoutfuel = 0, withfuel = 0, disamount = 0, taxamount = 0, totaldue = 0, Airport = 0,
Total = 0;
Also, some of them, put them as short int cuz you dont need big range of numbers.
(well thats for big programs.. wont need it now tbh.. it's only for big programs..
it just let you learn the technic) :P
GLuck compiling it :p
-
=) got it all working nice ty for help