Im taking a C++ class and the assignment is to make a program that calculates sales tax and then saves it to a text doc that can be viewed later. I guessed on a lot of this stuff so I was wondering if anyone can peak at this code and offer some advice. Any help would be greatly, greatly appreciated!!!!
// Problem 5: Sales Tax,
// problem5.cpp
// This program calculates sales tax and puts it into a file
#include <iostream>
#include <iomanip> // needed for setw
#include <fstream> //needed for writing files out
using namespace std;
int main()
{
ofstream sales_tax_data;
outputFile.open("sales_tax_data.txt") //this creates the sales tax doc
char month[11];
int year;
double total_income;
float county_sales_tax, state_sales_tax, total_sales_tax;
// This is where the program collects data from you
cout << “Please enter the month for this report: \n”;
cin >> month;
cout << “Please enter the year for this report: \n”;
cin >> year;
cout << “Please enter the total income for this month: \n”;
cin >> total_income;
Try splitting up the program into functions so that main has less to do. Thats what I usually do, that way each function takes care of its own.
Also it may be easier to use a class for tax and output the tax object but what you've got there is good.