hello everyone,
I've been trying to debug my program and have fixed most of them... however, I'm once again at the point that I'm staring at the codes... but feeling clueless........
Could someone please help....
Thanks so much
here are the error code
prog4.cc: In function `int main()':
prog4.cc:57: parse error before `,'
prog4.cc: In function `float CalculatePremium(int, char, basic_string<char,strin
g_char_traits<char>,__default_alloc_template<false ,0> >)':
prog4.cc:86: ANSI C++ forbids comparison between pointer and integer
prog4.cc:182: ANSI C++ forbids comparison between pointer and integer
and the following is the code....(sorry, it is long)
staring line #14
Code:#include <iostream> #include <string> #include <iomanip> #include <fstream> using namespace std; float CalculatePremium (int age, char gender, string type_coverage); //function prototype int main() { string first_name; //declare string variable first name string last_name; //declare string variable last name string gender; //declare string variable gender int age; //declare int variable age string type_coverage; //declare string variable type of coverage string club_member; //declare string variable health club //member string smoker; //declare string variable smoker int zip_code; //declare int variable zip code int premium; //declare int variable premium ifstream inFile; //declare file streams ofstream outFile; inFile.open("inputdata"); //opens the file if(!inFile) { cout << "Input file failed!" << endl; return 1; //terminates the program if input fails } inFile >> first_name >> last_name >> gender >> age >> type_coverage >> club_member >> smoker >> zip_code; //assigns input values from inFile cout << first_name << last_name << gender << age << type_coverage << club_member << smoker << zip_code; //echos the input on the monitor while (inFile) //looping in capturing & //processing input data { premium = CalculatePremium (int age, char gender, string type_coverage); outFile << first_name << last_name << type_coverage << zip_code << premium ; //output premium to file output inFile >> first_name >> last_name >> gender >> age >> type_coverage >> club_member >> smoker >> zip_code; //assigns input values to inFile outFile.open("output"); //creates output data } outFile.open("output"); if(!outFile) { cout << "Output file failed!" << endl; return 1; //terminates the program if output fials } } float CalculatePremium (int age, char gender, string type_coverage) { float basic_premium; //declare float variable basic premium float discount_premium; //declare float variable discount premium float premium; //declare float variable adjusted premium string club_member; //declare string variable health club //member string smoker; //declare string variable smoker int zip_code; //declare int variable zip code if (gender == "male") //premium calcuation for male users { if (age < 25 ) //premium calculation for male under age //25 { if (type_coverage == "single") //premium calculation for single //male under 25 { basic_premium = 65.00; } else //premium calculation for male //under 25 with family { basic_premium = 175.00; } } else if (age >= 25 && age <35) //premium calculation for male 25-34 { if (type_coverage == "single") //premium calculation for single male //25-34 { basic_premium = 85.00; } else //premium claculation for male //25-34 w/ family { basic_premium = 215.00; } } else if (age >= 35 && age <45) //premium calculation for male 35-44 { if (type_coverage == "single") //premium calculation for single male //35-44 { basic_premium = 110.00; } else //premium calculation for male 35-44 w/ //family { basic_premium = 325.00; } } else if (age >= 45 && age <55) //premium calculation for male 45-54 { if (type_coverage == "single") //premium calculation for single male //45-54 { basic_premium = 175.00; } else //premium calculation for male 45-54 w/ //family { basic_premium = 450.00; } } else if (age >= 55 && age <65) //premium calculation for male 55-64 { { if (type_coverage == "single") //premium calcualation for single male //55-64 { basic_premium = 325.00; } else //premium calculation for male 55-64 //w/family { basic_premium = 625.00; } } else //premium calculation for male 65 and //above { if (type_coverage == "single") //premium calculation for single male 65 //and above { basic_premium = 450.00; } else //premium calculation for male >=65 w/ //family { basic_premium = 850.00; } } } if (gender == "female") //premium calcuation for female users { if (age < 25 ) //premium calculation for female under age //25 { if (type_coverage == "single") //premium calculation for single female //under 25 { basic_premium = 60.00; } else //premium calculation for female under 25 //w/ family { basic_premium = 165.00; } } else if (age >= 25 && age <35) //premium calculation for female 25-34 { if (type_coverage == "single") //premium calculation for single female //25-34 { basic_premium = 75.00; } else //premium claculation for female 25-34 w/ //family { basic_premium = 210.00; } } else if (age >= 35 && age <45) //premium calculation for female 35-44 { if (type_coverage == "single") //premium calculation for single female //35-44 { basic_premium = 100.00; } else //premium calculation for female 35-44 w/ //family { basic_premium = 310.00; } } else if (age >= 45 && age <55) //premium calculation for female 45-54 { if (type_coverage == "single") //premium calculation for single female //45-54 { basic_premium = 150.00; } else //premium calculation for female 45-54 w/ //family { basic_premium = 425.00; } } else if (age >= 55 && age <65) //premium calculation for female 55-64 { if (type_coverage == "single") //premium calcualation for single female //55-64 { basic_premium = 310.00; } else //premium calculation for female 55-64 //w/family { basic_premium = 595.00; } } else //premium calculation for female 65 and //above { if (type_coverage == "single") //premium calculation for single female 65 //and above { basic_premium = 425.00; } else //premium calculation for female >=65 w/ //family { basic_premium = 795.00; } } } if (smoker == "NonSmoker" && club_member == "Club") { discount_premium = basic_premium * 0.9; //10% discount for non-smoker with health club membership } else if (smoker == "NonSmoker" && club_member == "NonClub") { discount_premium = basic_premium * 0.95; //5% discount for non-smoker without health club membership } else if (smoker == "Smoker" && club_member == "Club") { discount_premium = basic_premium * 0.95; //5% discount for smoker with health club membership } else { discount_premium = basic_premium; //no discount for smoker without health club membership } if (zip_code == 10000) { premium = discount_premium + 20; //adjust premium by $20 } else if (zip_code == 10001) { premium = discount_premium; //premium stays the same } else if (zip_code == 10002) { premium = basic_premium +30; //raise premium by $30 } return premium; }