Visual enhancement

This is a discussion on Visual enhancement within the C++ Programming forums, part of the General Programming Boards category; Hello, I've done a program to calcute employee's salary for an assignment and it's doing everything we were asked for, ...

  1. #1
    Kaf
    Kaf is offline
    Registered User
    Join Date
    Oct 2008
    Posts
    4

    Visual enhancement

    Hello,
    I've done a program to calcute employee's salary for an assignment and it's doing everything we were asked for, but I would like it to look a bit nicer. Is there some way to customize the window or add buttons or whatever ?
    Hope it's the right place to post this.
    Here is the code:
    insert
    Code:
    #include <stdlib.h>
    #include <stdio.h>
    #include <iostream>
    using namespace std;
    int main(void) {
       int n;
       int hoursw;
       double hourr;
       double salary;
       double itemr;
       int itemn;
       double grosss;
       system ( "color A" );
       do {
       printf("Please select one of the following options:\n \n1 Managers \n2 Hourly Worker \n3 Comission Worker \n4 Piece Worker \n0 Exit\n\nYour choice: ");
       scanf_s("%d", &n);
       switch (n) {
          case 1: {
             printf("\nThe employee's pay is 2000 S$\n");
    		 system("PAUSE");
    		 system ("cls");
    		 break;
          }
    	  case 2: {
    		  printf("\nPlease enter hourly worker's fixed hourly wage: \n");
    		  cin >> hourr;
    		  printf("\nPlease enter number of hours worked: \n");
    		  cin >> hoursw;
    		  if (hoursw<=40) {
    				salary = hourr*hoursw;
    				cout << "\nThe employee's salary is " << salary << " S$" << endl;
    		  }
    		  else {
    			  salary = hourr*40+(hoursw-40)*(1.5*hourr);
    			  cout << "\nThe employee's salary is " << salary << " S$" << endl;
    		  }
    		 system("PAUSE");
    		 system ("cls");
    		 break;
    	  }
          case 4: {
    		  printf("\nPlease enter number of items produced: \n");
    		  cin>>itemn;
    		  printf("\nPlease enter the fixed amount of money per item produced: \n");
    		  cin>>itemr;
    		  salary = itemn*itemr;
    			  cout << "\nThe employee's salary is " << salary << " S$" << endl;
    			  system("PAUSE");
    			  system ("cls");
    			  break;
    	  }
          case 3: {
             printf("\nPlease enter employee's gross weekly sales: \n");
    		 cin>>grosss;
    		 salary = grosss*5.7/100+250;
    			 cout << "\nThe employee's salary is " << salary << " S$" << endl;
    			 system("PAUSE");
    			 system ("cls");
    			 break;
    			 
          }
    	  case 0: {
    		  return 0;
    		  break;
    	  }
          default: {
             printf("\nPlease enter 1, 2, 3 or 4.\n");
    		 system("PAUSE");
    		 system ("cls");
             break;
    	  }
    	}
    }
    while ( "n!=0" );
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Buttons? In a console window? No, that can't happen.

    There are APIs for making fancy windows, but you'd have to spend a little time learning how to use them (and be relatively proficient in C beforehand).

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    I spot several problems in the code...
    And you really should make up your mind if this is C or C++...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Kaf
    Kaf is offline
    Registered User
    Join Date
    Oct 2008
    Posts
    4
    Thanks for the quick answers.

    @ Tabstop: Ok, I'll try to find some information about APIs, and see what I can do with it.

    @Elysia: Could you please let me know what are my mistakes ? So far when I run it I only get some bug when prompted to enter 1,2,3,4 or 0 and if I enter several numbers or a letter, the program will stop functionning.

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,543
    As I said first, make up your mind if this is C or C++ first.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Kaf
    Kaf is offline
    Registered User
    Join Date
    Oct 2008
    Posts
    4
    Well, I'm supposed to do it in C++ and use no other language. Plus I've never used C before.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Kaf View Post
    Well, I'm supposed to do it in C++ and use no other language. Plus I've never used C before.
    Then you should replace all those printf's with cout statements, and replace scanf_s() with cin statements, to begin with.

    I personally would also like to see some of your variables that are only used within ONE section of the bit switch that they are moved into the case where they are needed.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Kaf
    Kaf is offline
    Registered User
    Join Date
    Oct 2008
    Posts
    4
    Hello,
    When I replace all the printf with cin, I get this error: "error C2064: term does not evaluate to a function taking 1 arguments" .
    Is there a way to replace scanf_S with something that allows the user to enter only one character, and make sure that it is an number ?

  9. #9
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I would help quite a lot of you could post which line that corresponds to, and two lines of code either side from the actual code (5 lines from your code in total).

    Basically, the compiler is telling you that there is something in your code it thinks should be a function call, but the name given isn't something that it can figure out as a function, e.g.
    Code:
    int x;
      x(1)
    x is an integer, not a function, so you get this error.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #10
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    Posts
    111
    I think you need to read a C++ book.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  2. C++ std routines
    By siavoshkc in forum C++ Programming
    Replies: 33
    Last Post: 07-28-2006, 12:13 AM
  3. load gif into program
    By willc0de4food in forum Windows Programming
    Replies: 14
    Last Post: 01-11-2006, 09:43 AM
  4. Errors with including winsock 2 lib
    By gamingdl'er in forum C++ Programming
    Replies: 3
    Last Post: 12-05-2005, 07:13 PM
  5. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21