I'm new to C++ I don't understand why I'm getting this error. Out of 5 statements that are similar 3 mark error but the other two are okay. The error is in the main function.
#include <iostream>
using namespace std;
// Function declaration
void getGallons(int wall);
void getHours(int gallons);
void getCostpaint(int gallons, int pricePaint);
void getLaborcharges(int hours);
void getTotalcost(int costPaint, int laborCharges);
// Function definition
void getGallons(int wall)
{
int gallons;
gallons = wall / 112;
cout << "Number of gallons of paint required: " << gallons << endl;
}
// Function definition
void getHours(int gallons)
{
int hours;
hours = gallons * 8;
cout << "Hours of labor required: " << hours << endl;
}
// Function definition
void getCostpaint(int gallons, int pricePaint)
{
int costPaint;
costPaint = gallons * pricePaint;
cout << "The cost of paint: " << costPaint << endl;
}
// Function definition
void getLaborcharges(int hours)
{
int laborCharges;
laborCharges = hours * 35;
cout << "The labor charge: " << laborCharges << endl;
}
// Funtion definition
void getTotalcost(int costPaint, int laborCharges)
{
int totalCost;
totalCost = costPaint + laborCharges;
cout << "The total cost of the job: " << totalCost << endl;
}
// The main method
int main()
{
int wall;
int pricePaint;
cout << "Enter square feet of wall: ";
cin >> wall;
cout << "Enter price of paint per gallon: ";
cin >> pricePaint;
getGallons(wall);
getHours(gallons); // error here
getCostpaint(gallons, pricePaint);
getLaborcharges(hours); // error here
getTotalcost(costPaint, laborCharges); //error here
return 0;
}
This lesson focused on using functions and passing parameters in the code. I'm not supposed to use global variables. If you have a better way to do this please share.