I wrote this program for my homework, I added a ton of Windows things for the User Interface, BASIC stuph, thanks to Prelude and Shadow!
I am looking for 3 thingsCode://Taxes //Lucas Campbell, Period 1, Computer Science AP /*--Includes--*/ #include <iostream.h> // cout & cin #include <iomanip.h> // setiosflags() & setprecision() #include <time.h> // time_t & ctime() #include <conio.h> // getch() #include <windows.h> // manipulations of console and handlers /*------------*/ // NOTE: to run on Unix platform use system() to modify for conio and windows // Function prototypes int full_screen(); int kill_cursor(); void clrscrn(); // End prototypes //Main! int main(int argc, char* argv[]) // Accepts arguments { // Declarations time_t timel = time(NULL); // Get time for ctime() const double fedTax=0.15, FICA = 0.08, stateTax = 0.032; // Constants for rates double hoursWorked, hourlyRate, gross, net, tmp1, tmp2, tmp3; // Variables full_screen(); // We like BIG screens! kill_cursor(); // Can't have a mouse in DOS (technically) // Done with declarations if(argc > 1) // Make sure we don't have anymore program arguments { cout<<"This program doesn't accept arguments!"<<endl; return 0; } cout<<setiosflags(0x0100 | 0x1000); // showpoint & fixed cout<<"\t\t\tWelcome to Taxes\t\t"<<ctime(&timel); // Title and date //Output / Input block cout<<endl<<"Hours worked: "; cin>>hoursWorked; // Storing in hoursWorked cout<<endl<<"Hourly rate: "; cin>>hourlyRate; // Storing in hourlyRate cout<<endl<<"Press any key to see your taxes!"<<endl; getch(); // pause for key-press clrscrn(); // clear screen // NEW SCREEN HERE cout<<"\t\t\t\t\t\t\t"<<ctime(&timel)<<endl; //date in corner cout<<"Hours worked\t\t"<<setprecision(0x0000) <<hoursWorked<<endl; // displays no decimal for output cout<<"Hourly rate\t\t"<<setprecision(0x0002) <<hourlyRate<<endl; // now displays to two decimals from now on // Math / Output section gross = (hoursWorked * hourlyRate)+0.00001; cout<<endl<<"Gross pay\t\t" <<gross<<endl; tmp1 = (fedTax * gross) + 0.0001; // 0.001 for truncation cases cout<<endl<<"Federal tax(15%)\t" <<tmp1<<endl; tmp2 = (FICA * gross) + 0.0001; cout<<"FICA (8%)\t\t" <<tmp2<<endl; tmp3 = (stateTax * gross) + 0.0001; cout<<"State tax (3.2%)\t" <<tmp3<<endl; net = (gross - (tmp1+tmp2+tmp3)); cout<<endl<<"Net pay\t\t\t" <<net<<endl<<endl; // end section cout<<"Press return to continue"<<endl; getch(); // pause for user return 0; } int full_screen() // Maximize screen { keybd_event(VK_MENU,0x38,0,0); keybd_event(VK_RETURN, 0x1c, 0,0); keybd_event(VK_RETURN, 0x1c, KEYEVENTF_KEYUP, 0); keybd_event(VK_MENU, 0x38, KEYEVENTF_KEYUP, 0); return 0; } int kill_cursor() // no mouse in fullscreen { CONSOLE_CURSOR_INFO cci; cci.dwSize = 1; cci.bVisible = FALSE; SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE), &cci); return 0; } void clrscrn() // Clear screen { //declaring objects COORD coordScreen = { 0, 0 }; DWORD cCharsWritten; CONSOLE_SCREEN_BUFFER_INFO csbi; DWORD dwConSize; HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); //GET READY FOR HANDLERS! //end declarations GetConsoleScreenBufferInfo(hConsole, &csbi); // Set handlers dwConSize = csbi.dwSize.X * csbi.dwSize.Y; // Change coords FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); GetConsoleScreenBufferInfo(hConsole, &csbi); // rematch buffers FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); SetConsoleCursorPosition(hConsole, coordScreen); // rematch buffers to coords }
An explanation to what REALLY happens in those clrscrn() full_screen() and kill_cursor
a shorter way of doing this whole program
and a way so that the net pay is not rounded
also (don't want to use ios::whatever)



LinkBack URL
About LinkBacks



Seriously, though, the program is about as small as it can be...no worries...
Have a nice day.