Yes I know thats messy. The program is supposed to display a table of what quantity you entered, description, and cost, etc. I have a few problems I can't seem to fix. If theres more than single digits inside the quantity column the description won't line up. Heres sorta what I'm talking about:Code:// September 27, 2003 // Takes input numbers for a register and calculates cost #include <iostream.h> #include <iomanip.h> #define __USE_STD_IOSTREAM int main(void) { // Declarations int TV = 0; int VCR = 0; int CTRLR = 0; int CDS = 0; int RCRDR = 0; float subtotal = 0; float sales_tax = 0; float total = 0; float TVcost = 0; float VCRcost = 0; float CTRLRcost = 0; float CDScost = 0; float RCRDRcost = 0; // Output / Input cout << "\n\nHow many TVs were sold? "; cin >> TV; cout << "\nHow many VCRs were sold? "; cin >> VCR; cout << "\nHow many remote controls were sold? "; cin >> CTRLR; cout << "\nHow many CDs were sold? "; cin >> CDS; cout << "\nHow many tape recorders were sold? "; cin >> RCRDR; cout << "\n\n"; // Calculations TVcost = TV * 400; VCRcost = VCR * 220; CTRLRcost = CTRLR * 35.20; CDScost = CDS * 300; RCRDRcost = RCRDR * 150; subtotal = TVcost + VCRcost + CTRLRcost + CDScost + RCRDRcost; sales_tax = subtotal * .825; total = subtotal + sales_tax; // Output cout << "QTY DESCRIPTION UNIT PRICE TOTAL PRICE\n" << "--- ----------- ---------- -----------\n" << TV << setw(3) << " TV 400.00"; cout << setprecision(2) << showpoint << fixed << TVcost << "\n"; cout << VCR << setw(3) << " VCR 220.00" << VCRcost << "\n" << CTRLR << setw(3) <<" REMOTE CTRLR 35.20" << CTRLRcost << "\n" << CDS << setw(3) << " CD PLAYER 300.00" << CDScost << "\n" << RCRDR << setw(3) << " TAPE RECORDER 150.00"<< RCRDRcost << "\n" << setw(45) << "-----------\n" << "SUBTOTAL " << setfill('*') << setw(7) << subtotal << "\n" << "TAX" << setfill(' ') << setw(15) << sales_tax << "\n" << "TOTAL" << setw(13) << total << "\n\n"; return 0; // Terminate main }
That and I can't get fixed and showpoint to work. And once I get them working I can't figure out how to get them to only work on the total price of things so they will display two decimals, and not have the quantity showing decimals.Code:QTY DESCRIPTION --- ------------------ 1 TV 10 VCR