When running program output will not stay aligned.Help please!!

#include <iostream>
#include <string>
using namespace std;

int main() {
double loan_Payment;
double insurance;
double gas;
double oil;
double tires;
double maintenance;


/// text setup
std::cout.width(30); std::cout << std::left << "Loan Payment";

std::cout.width(15); std::cin >> std::right >> loan_Payment;
cin.ignore();


std::cout.width(30); std::cout << std::left << "Insurance";

std::cout.width(15); std::cin >> std::right >> insurance;
cin.ignore();


std::cout.width(30); std::cout << std::left << "Gas";

std::cout.width(15); std::cin >> std::right >> gas;
cin.ignore();


std::cout.width(30); std::cout << std::left << "Oil";

std::cout.width(15); std::cin >> std::right >> oil;
cin.ignore();


std::cout.width(30); std::cout << std::left << "Tires";

std::cout.width(15); std::cin >> std::right >> tires;
cin.ignore();


std::cout.width(30); std::cout << std::left << "Maintenance";

std::cout.width(15); std::cin >> std::right >> maintenance;
cin.ignore();


// adding total.yearly total, 10%

std::cout.width(30); std::cout << std::left << "Total";

std::cout.width(15); std::cout << std::right << (loan_Payment + insurance + gas +oil + tires + maintenance) << endl;

std::cout.width(30); std::cout << std::left << "Yearly Total";

std::cout.width(15); std::cout << std::right << (12 * (loan_Payment + insurance + gas + oil + tires + maintenance)) << endl;

std::cout.width(30); std::cout << std::left << "10%";

std::cout.width(15); std::cout << std::right << (12 * (loan_Payment + insurance + gas + oil + tires + maintenance))*.10 << endl;
//if yearly total is greater than 1000 add 10 percent of the yearly total
double yearly_total;
yearly_total = (12 * (loan_Payment + insurance + gas + oil + tires + maintenance));
if (yearly_total >= 1000)

std::cout.width(30); std::cout << std::left << "Grand Total";

std::cout.width(15); std::cout << std::right << ((12 * (loan_Payment + insurance + gas + oil + tires + maintenance))*.10) + (12 * (loan_Payment + insurance + gas + oil + tires + maintenance)) << endl;






}
Topic archived. No new replies allowed.