Thread: Simple check program

  1. #1
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765

    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.
    The world is waiting. I must leave you now.

  2. #2
    Registered User smokeybear's Avatar
    Join Date
    Jun 2002
    Posts
    31
    How long have you been writing?
    -Compiler
    --Dev-C++
    -Projects
    --Adventures of Lakod(0%)
    -----------------------------------------
    Site - www.cplusprogsm.cjb.net
    Forums - http://pub92.ezboard.com/faeiforumsfrm1

  3. #3
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > 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?
    Last edited by Shadow; 06-05-2002 at 04:19 PM.
    The world is waiting. I must leave you now.

  4. #4
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    > Now, what about my program?
    Bah!
    I forgot about overtime! I think I have it pretty much done for what I had intended.
    The world is waiting. I must leave you now.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-27-2005, 09:50 PM
  2. Need help with simple, simple program.
    By LightsOut06 in forum C Programming
    Replies: 5
    Last Post: 09-01-2005, 08:31 PM
  3. Problem with simple XOR program
    By spike_ in forum C++ Programming
    Replies: 8
    Last Post: 08-17-2005, 12:09 AM
  4. Simple Timer, Call external program,
    By bliss in forum C++ Programming
    Replies: 2
    Last Post: 06-02-2005, 11:21 PM
  5. fopen();
    By GanglyLamb in forum C Programming
    Replies: 8
    Last Post: 11-03-2002, 12:39 PM