I am trying to right align my numbers to make them look like this:
[TEX]
Total Collected: $ 26572.89
Sales: $ 25068.76
County Sales Tax: $ 501.38
State Sales Tax: $ 1002.75
[/TEX]
The problem is i dont know how to format it in my code. Here is my code that i have so far:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
//Declare variables
const double STATE_SALES_TAX_RATE = 0.04;
const double COUNTY_SALES_TAX_RATE = 0.02;
const double SALES_TAX = 0.06;
string month;
int year;
double totalCollected;
double productSales;
double countySalesTax;
double stateSalesTax;
double totalIncome;
cout << "Enter the month: ";
getline(cin, month);
cout << "Enter the year: ";
cin >> year;
cout << "Total amount collected at register: ";
cin >> totalCollected;
productSales = (totalCollected) / 1.06;
countySalesTax = productSales * COUNTY_SALES_TAX_RATE;
stateSalesTax = productSales * STATE_SALES_TAX_RATE;
totalIncome = countySalesTax + stateSalesTax;
//Display the monthly figures
cout << "\n"<< month << " "<< year <<"\n";
cout << "----------\n";
cout << fixed << setprecision(2);
cout << "Total Collected: " << setw(12) << "$ " << totalCollected << endl;
cout << "Sales: " << setw(12) << "$ " << productSales << endl;
cout << "County Sales Tax: " << setw(12) << "$ " << right<<countySalesTax << endl;
cout << "State Sales Tax: " << setw(12) << "$ " << stateSalesTax << endl;
cout << "Total Sales Tax: " << setw(12) << "$ " << totalIncome << endl;
system("pause");
return 0;
}