Can someone please point out to me what I'm doing wrong . Below is my source code for a program I wrote to calculate the cost of carpet & installation given the length,width, discount and cost per sq. foot. Everything works fine except that it doesn't compute and less the discount amount. Someone please help.

Code:
```#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

using namespace std;

const float labor = 0.35;
const float tax = 0.085;

void getData (int &length, int&width, int &discount, float &cost);
void calculate (int length, int width, int discount, float cost, float &totalLabor, float &totalCarpet, float &installation, float &subtotal, float &total, float &taxamount, float &discountamount);
void printResult(int length, int width,int discount,float cost,float totalLabor,float totalCarpet,float installation,float discountamount,float subtotal,float taxamount,float total);

int main ()
{
int length,width,discount;
float cost,totalLabor,totalCarpet,installation,subtotal,total,discountamount,taxamount;

getData(length,width,discount,cost);
calculate(length,width,discount,cost,totalLabor,totalCarpet,installation,subtotal,total,taxamount,discountamount);
printResult(length,width,discount,cost,totalLabor,totalCarpet,installation,discountamount,subtotal,taxamount,total);

system ("PAUSE");
return EXIT_SUCCESS;
}

void getData(int &length, int &width, int &discount, float &cost)
{
cout << "Length of the room (feet)? " << endl;
cin >> length;
cout << "Width of the room (feet)? " << endl;
cin >> width;
cout << "Customer discount (percent)? " << endl;
cin >> discount;
cout << "Cost per square feet (xxx.xx)? " << endl;
cin >> cost;
}

float calcInstall (int length, int width, float cost, float &totalLabor, float &totalCarpet)
{

totalLabor=length*width*labor;
totalCarpet=length*width*cost;

}

float calcSubtotal (float installation,int discount,float &discountamount)
{

discountamount = installation*(discount/100);

return installation-discountamount;
}

float calcTotal (float subtotal,float &taxamount,float &total)
{
taxamount=subtotal*tax;
total=subtotal+taxamount;

}

void calculate (int length, int width, int discount, float cost, float &totalLabor, float &totalCarpet, float &installation, float &subtotal, float &total, float &taxamount, float &discountamount)
{

installation=calcInstall(length,width,cost,totalLabor,totalCarpet);
subtotal=calcSubtotal(installation,discount,discountamount);
total=calcTotal(subtotal,taxamount,total);
}

void printMeasurement (int length,int width)
{
cout<<"                       THE BROOKLYN COLLEGE CARPET STORE" << endl;
cout    <<"                             ABDOOL RAHEEM, Owner" <<endl << endl << endl;
cout <<"                                  MEASUREMENT" << endl << endl;;
cout << right << setw(35) << "Length" << setw(10) << length << left << setw(34)
<<" feet" << endl;
cout << right << setw(35) << "Width" << setw(10) <<width << left << setw(34)
<< " feet" << endl;
cout << right << setw(35) << "Area" << setw(10) << length * width << left
<< setw(34) <<" square feet" << endl << endl << endl;

}

void printCharges(float cost,float totalCarpet,float totalLabor,float installation,int discount,float discountamount,float subtotal,float taxamount,float total)
{
cout <<"                                    CHARGES"<<endl<<endl;
cout << left << setw(20) << "DESCRIPTION" << right << setw(20)
<< "COST/SQ FT" << setw(20) << "CHARGE/ROOM" << endl;
cout << left << setw(20) << "Carpet" << right << setw(20)<< fixed
<< setprecision(2) << cost << setw(20)
<< setprecision(2) << totalCarpet << endl;
cout << left << setw(20)<< "Labor" << right << setw(20) << "0.35"
<< setw(20) << setprecision(2) << totalLabor << endl << endl;
cout << left << setw(20) << "INSTALLED PRICE" << right << setw(20)
<< "" << setw(20) << setprecision(2) << installation << endl;
cout << left << setw(20) << "Discount" << right << setw(20) << ""
<< setw(20) << setprecision(2) << discountamount << endl;
cout << right << setw(60) << "----------" << endl;
cout << left << setw(20) << "Sub Total" << right << setw(20) << ""
<< setw(20) << setprecision(2) << subtotal << endl;
cout << left << setw(20) << "Tax" << right << setw(20) << "" << setw(20)
<< setprecision(2) << taxamount << endl;
cout << left << setw(20) << "Total" << right << setw(20) << "" << setw(20)
<< setprecision(2) << total << endl;

}
void printResult(int length, int width,int discount,float cost,float totalLabor,float totalCarpet,float installation,float discountamount,float subtotal,float taxamount,float total)
{
printMeasurement (length,width);
printCharges (cost,totalCarpet,totalLabor,installation,discount,discountamount,subtotal,taxamount,total);
}```

2. The problem is in the function calcSubtotal:

Code:
```float calcSubtotal (float installation, int discount, float& discountamount)
{
discountamount = installation * (discount / 100);

return installation - discountamount;
}```
The variable discount is an integer, so (discount / 100) returns 0 for anything less than 100. To fix this you can cast the discount variable to a float type, or simply change the type of the discount variable to a float.

Code:
```float calcSubtotal (float installation, float discount, float& discountamount)
{
...
}

// or

float calcSubtotal (float installation, int discount, float& discountamount)
{
discountamount = installation * ((float)discount / 100);

return installation - discountamount;
}```

3. Be careful of integer division:
Code:
```float calcSubtotal (float installation,int discount,float &discountamount)
{

discountamount = installation*(discount/100);

return installation-discountamount;
}```
(discount / 100) will always be 0 for any value of discount less than 100.

4. Hey,

I got it working. Thank you so much!