1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
#include <iostream>
#include <string>
#include <iomanip>
#include <windows.h>
using namespace std;
int main ()
{
// Personal Additions
SetConsoleTitle( TEXT("Monthly Sales Tax by me -_-"));
string name;
string Line1 = "\n\n===========================================================\n\n";
string Line2 = "\n===========================================================";
// Months Array
string months[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
double total, sales, sstax, sstaxv, cstax, cstaxv, ttax;
int m, year;
// NAME
cout << "What is your Name? ";
getline(cin, name);
cout << "\nHello " << name << "!\n";
Sleep(1000);
// INTRO
cout << Line1;
cout << "Please answer the following questions...";
cout << Line1;
// MONTH
cout << "\n - Month (1-12)? ";
cin >> m;
while(m < 1 || m > 12)
{
cout << Line2;
cout << "\nError Id10T :]";
cin.clear();
while(cin.get() != '\n');
cout << "\n\n - What Is The Month (ex 1-12)? ";
cin >> m;
}
// YEAR
cout << Line2;
cout << "\n - Year (ex 2013)? ";
cin >> year;
while(year < 1000)
{
cout << Line2;
cout << "\nError Id10T :]";
cin.clear();
while(cin.get() != '\n');
cout << "\n\n - What Is The Year (ex 2013)? ";
cin >> year;
}
// TOTAL AMOUNT
cout << Line2;
cout << "\n - Total Amount (ex 10.01)? ";
cin >> total;
while(total < 0)
{
cout << Line2;
cout << "\nError Id10T :]";
cin.clear();
while(cin.get() != '\n');
cout << "\n\n - What Is The Total Amount (ex 10.01)? ";
cin >> total;
}
// tax variables
sstaxv = .04, cstaxv = .02;
//formulas
sales = total / (1 + sstaxv + cstaxv);
sstax = sales * sstaxv;
cstax = sales * cstaxv;
ttax = sstax + cstax;
cout << fixed << showpoint << setprecision(2);
//RESULT
cout << string(50, '\n');
cout << left << setw(7) << "Month: " << setw(13) << months[m-1];
cout << setw(5) << "Year: " << setw(5) << year << endl;
cout << Line2 << endl;
cout << left << setw(30) << "Total Collected:";
cout << "$" << right << setw(8) << total << endl;
cout << left << setw(30) << "Sales:";
cout << "$" << right << setw(8) << sales << endl;
cout << left << setw(30) << "County Sales Tax:";
cout << "$" << right << setw(8) << cstax << endl;
cout << left << setw(30) << "State Sales Tax:";
cout << "$" << right << setw(8) << sstax << endl;
cout << left << setw(30) << "Total Sales Tax:";
cout << "$" << right << setw(8) << ttax << endl;
cout << "\nPress enter to exit...";
cin.ignore();
cin.get();
cout << string(50, '\n');
cout << "Have a nice day " << name << "!!!";
Sleep(5000);
exit;
}
|