-
Simple check program
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. :D
-
How long have you been writing?
-
> How long have you been writing?
This program?
30 minutes - 1 hour.
( most of the time was take up by tweaking the code )
As far as actual C programming, at the max 6 months before my registered date.
I've had right around 11 years of DOS expierence and using a computer in a technical manner though.
I've touched the OLD BASIC, but didn't do a whole lot.
Is that a good enough answer?
Now, what about my program? :)
-
> Now, what about my program?
Bah!
I forgot about overtime! I think I have it pretty much done for what I had intended.