pricing program errors

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
#include <iostream>
#include <cmath>
using namespace std; //introduces namespace standard library

void getdata (int& length, int& width, float& costpersqfoot); //reads the length and width of the room and the cost per square foot
float InstalledPrice(int length, int width, float costpersqfoot); //calculates the installed price taking into account the labor cost 
                                                                  //the labor cost is a symbolic constant
float totalprice(float installation); //finds the total cost using the installed price and the tax rate
void printdata (int length, int width, float price); //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;
void PrintLines (int);

int main()
{
    int length, width, costpersqfoot;
    float installation, price, LABOR_COST, t, ip;
    
    int count, numLines; //loop control variable
    cout << "Input the number for the count." << endl;
    cin >> count; //enter number of lines you wants
    while (count <= numLines)
    {
        cin >> length >> width >> costpersqfoot;
        getdata (InstalledPrice);
        ip = InstalledPrice(t); //find installation cost
        totalprice(); //find total cost
        printdata (ip, t);
    }
    
    system("pause");
    return 0;
} //end of main

float installation, costpersqfoot, t, ip;
int length, width;

void getdata (float& t)
{
     cout << "Input the length, width, and cost per square foot" << endl;
     cin >> t;
}

float InstalledPrice (float t)
{
      return (length*width*costpersqfoot) + (length*width*LABOR_COST);
}

float totalprice (float t)
{
      return (installation*TAX_RATE);
}

void printdata (int length, int width, float price)
{
     cout << "The Installation cost is = " << ip << endl;
     cout << "The total price is include tax = " << t << endl;
}


At the moment, that is my program i created. I'm having errors in my "count loop". Im trying to read count for the loop. Also i'm not sure if my whole program is correct.
I need to:
-write a program that calculates the installation cost and the total cost of installing a carpet.
-Write the data using the printdata procedure.
-The data will be read using a count controlled for loop.

And the input should be:
3 (for the count)
23 13 18.20 //length, width, cost per square foot
28 15 20.60
14 11 25.53


Heres the shell or the psuedocode outline for the program)
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
//include libraries
//prototypes:
void getdata (int& length, int& width, float& costpersqfoot); 
float InstalledPrice (int length, int width, float costpersqfoot);
float total price (float installation);
void printdata (int length, int width, float price);
const float LABOR_COST = 0.35;
const float TAX_RATE = 0.05;

int main()
{
//declare length and width of type int
//declare installation cost and total cost of type float

//Read count for the loop
//for loop based on the count
{
//call get_data
//find installation cost
//find total cost
//Write the result with the printdata procedure
} //end for

//return from main
}//end of main

//define functions here, two void and two regular 


Also im having errors in other parts of my program. If anyone can help and find the problem, that would be really grateful. Thank you!
cin >> count; //enter number of lines you wants

Did you mean to store the number of lines in the variable named count? I think you meant to store it in the variable named numLines.

while (count <= numLines)
Here, you are comparing two variables. Your program only sets a value for one of them. What value is count supposed to have at the start of this loop?

So the loop is meant to end when count matches numLines? Well then, how do you expect count to change?
Last edited on
Topic archived. No new replies allowed.