For being useful, and handy at times, I decided to write this program.
If you would, tell me what I can do to improve it for the intended platform.
I use windows and gcc.
Code:
/*
Program:
Check.c
Purpose:
Figure out take home pay from a standard,
weekly check system
*/
#include <stdio.h>
#include <conio.h>
#include <math.h>
#include <time.h>
#include <windows.h>
void ClrScr ( void );
void FullScreen ( void );
void KillCursor ( void );
int main ( void )
{
int HourlyPay;
int HoursWorked;
int TakeHome;
int Gross;
char TaxChoice;
FullScreen();
ClrScr();
KillCursor();
printf("Enter your hourly pay:\n$");
scanf("%d", &HourlyPay);
printf("\nEnter your hours worked:\n");
scanf("%d", &HoursWorked);
Gross = HourlyPay * HoursWorked;
printf("\nHow much would you like to take out?\n");
printf("1 = 25 percent\n2 = 30 percent\n\n");
TaxChoice = getch();
switch(TaxChoice)
{
case '1':
TakeHome = .75 * Gross;
printf("You will take home:\n");
printf("$%d", TakeHome);
printf("\n\nPress any key..");
getch();
break;
case '2':
TakeHome = .70 * Gross;
printf("You will take home:\n");
printf("$%d", TakeHome);
printf("\n\nPress any key..");
getch();
break;
}
return 0;
}
void FullScreen ( void )
{
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);
}
void ClrScr ( void )
{
COORD coordScreen = {0, 0};
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD dwConSize;
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hConsole, &csbi);
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
FillConsoleOutputCharacter(hConsole, TEXT(' '),
dwConSize, coordScreen, &cCharsWritten);
GetConsoleScreenBufferInfo(hConsole, &csbi);
FillConsoleOutputAttribute(hConsole, csbi.wAttributes,
dwConSize, coordScreen, &cCharsWritten);
SetConsoleCursorPosition(hConsole, coordScreen);
}
void KillCursor ( void )
{
CONSOLE_CURSOR_INFO cci;
cci.dwSize = 1;
cci.bVisible = FALSE;
SetConsoleCursorInfo( GetStdHandle( STD_OUTPUT_HANDLE ), &cci );
}
P.S.
This program was written very quickly.