c++ - Functions not declared in this scope -
keep getting error functions try call not declared in scope. here code block. compiler returns error functions called "xxx not declared in scope" wasn't sure problem might be, i've included of code. sorry there lot. , on can offer.
here small example of not working properly.
void kitchenoption(void); int main() { kitchenoption(); } /****************************** * function name: kitchenoption * return type: none * parameters: none * description: gives kitchen options , updates global variable. * ****************************/ void kitchenoption(void) { std::cout << "you may add deluxe wooden cabinets , granite cabinets additional $20,000." << std::endl; std::cout << "if deluxe cabinets , countertops, please input 1." << std::endl; std::cout << "if not want deluxe cabinets , countertops, please input 2." << std::endl; std::cin >> kitchenchoice; if(kitchenchoice == 1) { std::cout << "you have selected deluxe cabinets , contertops. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(kitchenchoice == 2) { std::cout << "you have selected not have deluxe caibnets , countertops." << std::endl; } else { std::cout << "that not valid input." << std::endl; exit(1); } }
this^ function example of not working properly. rest of code below:
#include<iostream> using std::cout; using std::endl; using std::fixed; #include<iomanip> using std::setprecision; #include <stdlib.h> //fixed variable declarations , assignments float state_tax_rate = .075; float percent_profit = .25; float cost_per_square_ft = 66.67; //variable declarations , initial assignments double housesquarefootage = 0.0; double basichomecost = 0.0; double profit = 0.0; double nethomecost = 0.0; double taxes = 0.0; double totalhomecost = 0.0; double optionalfeaturescost = 0.0; double discount = 0.0; int housechoice = 0; int bedroomchoice = 0; int kitchenchoice = 0; int interiorchoice = 0; int loopvar = 1; int loopchoice = 0; //function declarations int houseoption(void); void welcomemessage(void); void bedroomoption(void) void kitchenoption(void); void designoption(void); void displaydiscount(void); void displaysummary(void); void dmorequoteoption(void); void thankyoumessage(void); int main() { do{ //reset variables housechoice = 0; bedroomchoice = 0; kitchenchoice = 0; interiorchoice = 0; optionalfeaturescost = 0; discount = 0; //welcome message welcomemessage(); //house option housechoice = houseoption(); if(housechoice == 1) { std::cout << "you have selected standard house." << std::endl; housesquarefootage = 3000; displaysummary(); morequoteoption(); } else if (housechoice == 2) { std::cout << "you have selected custom house." << std::endl; //bedroom option bedroomoption(); //kitchen option kitchenoption(); //design option designoption(); //discount displaydiscount(); //run calculations , report displaysummary(); } else { std::cout << "that not valid input" << std::endl; exit(1); } } while (loopvar <= 5); } /************************************* * function type: welcomemessage * return type: none * parameters: none * description: welcomes user house pogram * **********************************/ void welcomemessage(void) { std::cout << "weloome house selection program." << std::endl; std::cout << "this program allow select features for" << std::endl; std::cout << " , calculate costs 5 houses." << std::endl; } /************************************* * function name: houseoption * return type: int * parameters: none * description: gives house options , returns int save info. *********************************** / int houseoption(void) { std::cout << "would standard house or custom house?" << std::endl; std::cout << "input 1 standard house or 2 custom house." << std::endl; std::cin >> housechoice; return housechoice; } /********************************* * function name: bedroomoption * return type: none * parameters: none * description: gives bedroom options , updates globabl variable. * *****************************/ void bedroomoption(void) { std::cout << "you may add 1 or 2 bedrooms. each bedroom add 360 sq ft house." << std::endl; std::cout << "enter 0 no bedrooms, 1 one bedroom, or 2 two bedrooms." << std::endl; std::cin >> bedroomchoice; if(bedroomchoice == 0) { std::cout << "you have chosen not have bedrooms. square footage of house 3000." << std::endl; housesquarefootage = 3000; return housesquarefootage; } else if(bedroomchoice == 1) { std::cout << "you have chosen add 1 bedroom. square footage of house 3360." << std::endl; housesquarefootage = 3360; return housesquarefootage; } else if(bedroomchoice == 2) { std::cout << "you have chosen add 2 bedrooms. square footage of house 3720." << std::endl; housesquarefootage = 3720; return housesquarefootage; } else { std::cout << "that not valid input." << std::endl; exit(1); } } /****************************** * function name: kitchenoption * return type: none * parameters: none * description: gives kitchen options , updates global variable. * ****************************/ void kitchenoption(void) { std::cout << "you may add deluxe wooden cabinets , granite cabinets additional $20,000." << std::endl; std::cout << "if deluxe cabinets , countertops, please input 1." << std::endl; std::cout << "if not want deluxe cabinets , countertops, please input 2." << std::endl; std::cin >> kitchenchoice; if(kitchenchoice == 1) { std::cout << "you have selected deluxe cabinets , contertops. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(kitchenchoice == 2) { std::cout << "you have selected not have deluxe caibnets , countertops." << std::endl; } else { std::cout << "that not valid input." << std::endl; exit(1); } } /*************************** * function name: designoption * return type: none * parameters: none * description: gives design options , updates global variable. * *************************/ void designoption(void) { std::cout << "there 4 interior options , follows..." << std::endl; std::cout << "option 1: hardwood floors den, kitchen, , family room. cost: $10,000" << std::endl; std::cout << "option 2: of option 1 solid brass lighting fixtures in , out. cost: $20,000" << std::endl; std::cout << "option 3: of option 2 plush carpeting, ceramic tile, , real wood paneling. cost: $25,000" << std::endl; std::cout << "option 4: of option 3 gold kitchen , bath fixtures, jacuzzi , sauna. cost: $30,000" << std::endl; std::cout << "----" << std::endl; std::cout << "please input 0 no interior features, 1 option 1, 2 option 2, 3 option 3, or 4 option 4." << std::endl; std::cin >> interiorchoice; if(interiorchoice == 0) { std::cout << "you have chosen not have interior features." << std::endl; } else if(interiorchoice == 1) { std::cout << "you have selected option 1. adds $10,000 optional features cost." << std::endl; optionalfeaturescost += 10000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 2) { std::cout << "you have selected option 2. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 3) { std::cout << "you have selected option 3. adds $25,000 optional features cost." << std::endl; optionalfeaturescost += 25000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 4) { std::cout << "you have selected option 4. adds $30,000 optional features cost." << std::endl; option alfeaturescost += 30000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else { std::cout << "that not valid input." << std::endl; exit(1); } } /************************* * function name: displaydiscount * return type: none * parameters: none * description: checks discount , displays it. function performs role of calculatediscount(). * ************************/ void displaydiscount(void) { std::cout << "if optional features cost exceeds $30,000, 10% discount on optional features awarded." << std::endl; if(optionalfeaturescost >= 30000) { discount = optionalfeaturescost*0.1; std::cout << "an optional features cost of $" << setprecision(2) << fixed << optionalfeaturescost << " exceeds requirement of $30,000, , 10% discount of $" << setprecision(2) << fixed << discount << " has been awarded." << std::endl; } else { std::cout << "an optional features cost of $" << setprecision(2) << fixed << optionalfeaturescost << " not meet requirement of $30,000, , thus, no discount awarded." << std::endl; } } /*********************** * function name: displaysummary * return type: none * parameters: none * description: displays relevant info summary. function performs role of calculatefinalcost(). * *******************/ void displaysummary(void) { //calculating basic home cost basichomecost = housesquarefootage * cost_per_square_ft; //calculating profit profit = (basichomecost + optionalfeaturescost) * percent_profit; //calculating net home cost nethomecost = basichomecost + optionalfeaturescost + profit - discount; //calculating taxes taxes = nethomecost * state_tax_rate; //calculating totalhomecost totalhomecost = nethomecost + taxes; //reporting information std::cout << "house square footage: " << setprecision(2) << fixed << housesquarefootage << std::endl; std::cout << "basic home cost: " << setprecision(2) << fixed << basichomecost << std::endl; std::cout << "optional features cost: " << setprecision(2) << fixed << optionalfeaturescost << std::endl; std::cout << "discount: " << setprecision(2) << fixed << discount << std::endl; std::cout << "net home cost: " << setprecision(2) << fixed << nethomecost << std::endl; std::cout << "profit: " << setprecision(2) << fixed << profit << std::endl; std::cout << "taxes: " << setprecision(2) << fixed << taxes << std::endl; std::cout << "total home cost: " << setprecision(2) << fixed << totalhomecost << std::endl; { std::cout << "you have selected deluxe cabinets , contertops. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(kitchenchoice == 2) { std::cout << "you have selected not have deluxe caibnets , countertops." << std::endl; } else { std::cout << "that not valid input." << std::endl; exit(1); } } /*************************** * function name: designoption * return type: none * parameters: none * description: gives design options , updates global variable. * *************************/ void designoption(void) { std::cout << "there 4 interior options , follows..." << std::endl; std::cout << "option 1: hardwood floors den, kitchen, , family room. cost: $10,000" << std::endl; std::cout << "option 2: of option 1 solid brass lighting fixtures in , out. cost: $20,000" << std::endl; std::cout << "option 3: of option 2 plush carpeting, ceramic tile, , real wood paneling. cost: $25,000" << std::endl; std::cout << "option 4: of option 3 gold kitchen , bath fixtures, jacuzzi , sauna. cost: $30,000" << std::endl; std::cout << "----" << std::endl; std::cout << "please input 0 no interior features, 1 option 1, 2 option 2, 3 option 3, or 4 option 4." << std::endl; std::cin >> interiorchoice; if(interiorchoice == 0) { std::cout << "you have chosen not have interior features." << std::endl; } else if(interiorchoice == 1) { std::cout << "you have selected option 1. adds $10,000 optional features cost." << std::endl; optionalfeaturescost += 10000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 2) { std::cout << "you have selected option 2. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 3) { std::cout << "you have selected option 3. adds $25,000 optional features cost." << std::endl; if(kitchenchoice == 1) { std::cout << "you have selected deluxe cabinets , contertops. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(kitchenchoice == 2) { std::cout << "you have selected not have deluxe caibnets , countertops." << std::endl; } else { std::cout << "that not valid input." << std::endl; exit(1); } } /*************************** * function name: designoption * return type: none * parameters: none * description: gives design options , updates global variable. * *************************/ void designoption(void) { std::cout << "there 4 interior options , follows..." << std::endl; std::cout << "option 1: hardwood floors den, kitchen, , family room. cost: $10,000" << std::endl; std::cout << "option 2: of option 1 solid brass lighting fixtures in , out. cost: $20,000" << std::endl; std::cout << "option 3: of option 2 plush carpeting, ceramic tile, , real wood paneling. cost: $25,000" << std::endl; std::cout << "option 4: of option 3 gold kitchen , bath fixtures, jacuzzi , sauna. cost: $30,000" << std::endl; std::cout << "----" << std::endl; std::cout << "please input 0 no interior features, 1 option 1, 2 option 2, 3 option 3, or 4 option 4." << std::endl; std::cin >> interiorchoice; if(interiorchoice == 0) { std::cout << "you have chosen not have interior features." << std::endl; } else if(interiorchoice == 1) { std::cout << "you have selected option 1. adds $10,000 optional features cost." << std::endl; optionalfeaturescost += 10000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 2) { std::cout << "you have selected option 2. adds $20,000 optional features cost." << std::endl; optionalfeaturescost += 20000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 3) { std::cout << "you have selected option 3. adds $25,000 optional features cost." << std::endl; optionalfeaturescost += 25000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else if(interiorchoice == 4) { std::cout << "you have selected option 4. adds $30,000 optional features cost." << std::endl; option alfeaturescost += 30000; std::cout << "your optional features cost $" << setprecision(2) << fixed << optionalfeaturescost << std::endl; } else { std::cout << "that not valid input." << std::endl; 201,1 63%
always focus on first error because can cause of others. in case missing semi colon after
void bedroomoption(void)
which confusing compiler causing lot of fake errors.
Comments
Post a Comment