Hello,
I am new to programming and am taking an intro class. I am having trouble with XCode and getting my code to compile with multiple files. I am using headers, but I keep receiving the following errors.
On consoleUI.cpp, I get 2 errors:
1. No previous prototype for function "consoleUI"
2. No matching function for call "PaintJobEstimator"
On PaintJobEstimator.cpp, I get 1 error:
1. No previous prototype for function "PaintJobEstimator"
If anyone could help, I would be grateful. Thank you. Below is my code. I can't even compile to test if the logic works.
main.cpp:
consoleUI.cpp:
PaintJobEstimator.cpp:
consoleUI.h:
PaintJobEstimator.h:
I am new to programming and am taking an intro class. I am having trouble with XCode and getting my code to compile with multiple files. I am using headers, but I keep receiving the following errors.
On consoleUI.cpp, I get 2 errors:
1. No previous prototype for function "consoleUI"
2. No matching function for call "PaintJobEstimator"
On PaintJobEstimator.cpp, I get 1 error:
1. No previous prototype for function "PaintJobEstimator"
If anyone could help, I would be grateful. Thank you. Below is my code. I can't even compile to test if the logic works.
main.cpp:
Code:
#include <iostream>
// Include Header file
#include "consoleUI.h"
using namespace std;
void consoleUI();
int main()
{
consoleUI();
return 0;
}
consoleUI.cpp:
Code:
#include <iostream>
#include <iomanip>
// Include Header File
#include "PaintJobEstimator.h"
using namespace std;
// Begin Console UI
void consoleUI ()
{
int rooms = 0; // Number of Rooms
int cnt = 0; // Counter for rooms
double paint = 0.00; // Number of gallons of paint
double ceilPaint = 0.00; // Paint rounded up
double labor = 0.00; // Labor hours needed
double sqft = 0.00; // Square footage of wall
double laborCost = 0.00; // Cost of labor
double paintCost = 0.00; // Cost of paint
double priceOfPaint = 0.00; // Price of paint * paintCost
double totalCost = 0.00; // Total Cost
bool isValid = false; // Loop validation
// Input for rooms
cout<<"How many rooms would you like to paint?\n";
cin>>rooms;
cout<<"You entered: "<<rooms <<" rooms.\n";
// Input for Paint Cost
cout<<"What is the price of paint per gallon?\n";
cin>>paintCost;
// Input validation loop
while (! isValid)
{
// Loop for calculation of each room
for (cnt=0; cnt<=rooms; cnt--)
{
if (rooms > 0 && rooms <= 25)
{
cout<<"What is the total square footage for the walls of the entire room?\n";
cin>>sqft;
sqft += sqft;
if (sqft > 0.00)
{
if (paintCost >= 10.00)
{
isValid = true;
}
}
}
else
{
cout<<"Invalid entry.\n";
}
}
}
// Call function to compute costs
PaintJobEstimator (paint, labor, sqft, paintCost, laborCost, priceOfPaint);
// Output Costs
cout << fixed << setprecision(2);
cout <<"Number of gallons of paint: " << ceilPaint <<endl;
cout <<"Hours of labor: " << labor <<endl;
cout <<"Cost of paint: $"<< setw(7) << paintCost <<endl;
cout <<"Labor charge: $"<< setw(7) << laborCost <<endl;
cout <<"Total cost: $"<< setw(7) << totalCost <<endl;
}
PaintJobEstimator.cpp:
Code:
#include <stdio.h>
#include <math.h>
#include <cmath>
double PaintJobEstimator (double& ceilPaint, double& paint, double& labor, double& sqft, double& paintCost, double& laborCost, double& priceOfPaint, double& totalCost)
{
// Ceiling Function for gallons of paint
ceilPaint = sqft/115;
paint = ceil (ceilPaint);
// Cost of labor, paint & total costs
labor = ((sqft/115) * 8);
laborCost = labor * 18.00;
priceOfPaint = paint * paintCost;
totalCost = laborCost + priceOfPaint;
return 0;
}
consoleUI.h:
Code:
#ifndef Paint_Job_Estimator_consoleUI_h
#define Paint_Job_Estimator_consoleUI_h
void consoleUI ();
#endif
PaintJobEstimator.h:
Code:
#ifndef Paint_Job_Estimator_PaintJobEstimator_h
#define Paint_Job_Estimator_PaintJobEstimator_h
double PaintJobEstimator (double& ceilPaint, double& paint, double& labor, double& sqft, double& paintCost, double& laborCost, double& priceOfPaint, double& totalCost);
#endif