stuck on "undeclared functions" & "for loops"

Right now this is the program I created:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//include libraries
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std; //introduces namespace standard library

//prototypes
void getdata (int&, int&, float&); //reads the length and width of room and cost per square foot
float InstalledPrice (int, int, float); //calculates the installed price taking into account the labor cost. 
                                        //labor cost is a symbolic constant
float totalprice (float); //finds the total cost using the installed price and the tax rate
void printdata (int, int, float); //prints the length, width, and total cost for each data set
const float LABOR_COST = 0.35; //$0.35 per square foot
const float TAX_RATE = 0.05;

int main()
{ //start of main
    int length, width; //declare length and width of type int
    float installation, total, price, costpersqfoot; //declare installation cost and total cost of type float
    
    int num;
    const int MAXCOUNT = num; //read count for the loop
    int count;
    
    for (count = 0; count < MAXCOUNT; count++) //for loop based on the count
    { //start of for loop
        cout<< "Enter a number for the count: " <<endl;
        cin>> num;
        
        getdata (length, width, costpersqfoot); //call get_data
        installation = InstalledPrice (length, width, costpersqfoot); //find the installation cost
        total = totalprice (installation); //find total cost
        printdata (length, width, price); //write the result with the printdata procedure
        
    } //end for loop

    system("pause");
    return 0;
    
} //end of main

//define functions here, two void and two regular
void getdata (int& length, int& width, float& costpersqfoot)
{
     cout<< "Please enter length, width, and cost per square foot of the room\n";
     cin >> length >> width >> costpersqfoot;
}    

float InstalledPrice (int length, int width, float costpersqfoot)
{
      return (length*width*costpersqfoot) + (length*width*LABOR_COST); //formula to find installation cost with LABOR_COST
}

float totalprice (float installation)
{
      return (installation*TAX_RATE); //finding total cost with tax
}

void printdata (int length, int width, float price)
{
     cout<< "The cost for installation is = " << installation << endl;
     cout<< "The total cost with tax is = " << total << endl;
}


I'm supposed to find price for carpet considering their length, width, and cost per square foot with labor cost and tax.
I'm having problems at the end "void printdata" function where the installation and total isn't declared first. What should i put instead to fix it or is there anyway to solve the problem? I want to calculate (length*width*costpersqfoot) + (length*width*LABOR_COST) for installation.
Then installation*TAX_RATE for the total cost. But its only giving me 0 or just 1 for the answer earlier.

Also at my "for loop", I'm not sure if I used it correctly since im only a beginner. I wanted to read count for the loop and use for loop based on the count. So for example:
If i input 3 for the count then i would input length, width, costpersqfoot 3x
3
23 13 18.20 //length, width, costpersqfoot
28 15 20.60
14 11 25.53

or if i want to input the numbers 4 times, then it would be:
4
23 13 18.20
28 15 20.60
14 11 25.53
10 15 20.50


If anyone can help me, then that would be very much appreciated. Thank you!
1. Change the printdata method with the signature of void printdata (float installation, float total). Change the declaration, definition and calling places.

2. Move the couple of lines for getting the num outside of loop and put it after the declaration of num.

int num;
cout<< "Enter a number for the count: " <<endl;
cin>> num;
const int MAXCOUNT = num; //read count for the loop
int count;

3. Add the installation amount for calculating the total cost inclusive of tax.
total = installation + totalprice (installation); //find total cost
Topic archived. No new replies allowed.