C++ Code runs well, but currently outputting values to right but justified left and not lining up on the decimal. Can't use put_money, what am I missing?
Attempted using fprint and put_money, confirmed with classmate we're supposed to use setw(x).
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
const double taxRate = 0.09;
const double laborCPH = 35.0; //where CPH is Cost Per Hour
double costParts;
double costLabor;
double totalTax;
double totalDue;
string name;
double laborHours;
cout << "What is your name? ";
cin >> name;
cout << "How many hours of labor needed? ";
cin >> laborHours;
costLabor = laborHours * laborCPH;
cout << "What was the cost of the parts and supplies? ";
cin >> costParts;
cout << endl << endl;
totalTax = costParts * taxRate;
totalDue = costParts + totalTax + costLabor;
cout.precision(2);
cout << setw(25) << left << "Customer Name " << fixed << right << internal << name << endl;
cout << setw(25) << left << "Hours of Labor " << fixed << right << internal << laborHours << endl;
cout << setw(25) << left << "Cost for Labor " << fixed << right << internal << costLabor << endl;
cout << setw(25) << left << "Parts and Supplies " << fixed << right << internal << costParts << endl;
cout << setw(25) << left << "Tax " << fixed << right << internal << totalTax << endl;
cout << setw(25) << left << "Total Amount Due " << fixed << right << internal << totalDue << endl;
return 0;
}
Actual output:
What is your name? Jones
How many hours of labor needed? 4.5
What was the cost of the parts and supplies? 97
Customer Name Jones
Hours of Labor 4.50
Cost for Labor 157.50
Parts and Supplies 97.00
Tax 8.73
Total Amount Due 263.23
Desired output:
What is your name? Jones
How many hours of labor needed? 4.5
What was the cost of the parts and supplies? 97
Customer Name Jones
Hours of Labor 4.50
Cost for Labor 157.50
Parts and Supplies 97.00
Tax 8.73
Total Amount Due 263.23