Thread: how to program this

  1. #16
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    These guys are coming out of school, up to their ears in debt, full of high hopes only to discover their education was outdated before they were born... Not good!
    Especially after paying off their teachers when they can't hack it!

    Just a random thought are aeronautical engineers, in India, trained on Propeller powered planes or blimps; instead of jet aircraft?
    Paper airplanes.

  2. #17
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Quote Originally Posted by rags_to_riches View Post
    Paper airplanes.
    Haha.... except they have to pay some chinese kid to make them.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  3. #18
    Registered User
    Join Date
    Aug 2011
    Posts
    7
    haay ! you guys is so humble. tsk! im only 1st year student of IT. ok?

    is this correct? help





    Code:
    
    
    #include <stdio.h>
    main()
    {
    
    float rph,bpd,tax,sss=250,pagibig=150,otp,bspc,bonus,cola,npay,gpay;
    int nhw,ndw,el;
    char ans=' ';
    clrscr();
    
    {
    
    
    
      printf("Enter Rate per Hour: ");
      scanf("%f",&rph);
      printf("Enter No. of Hours Worked: ");
      scanf("%int",&nhw);
      printf("Enter No. of Days Worked: ");
      scanf("%int",&ndw);
      if(ndw > 12)
      {
        printf("\nEnter upto 12 no. of days worked only.");
        getch();
      }
    }while(ndw > 12);
    
    bpd = nhw * rph;
    tax = bpd * 0.1;
    otp = (nhw - 8) * (rph) * (1.5);
    bspc= bpd * ndw;
    bonus = bspc * 0.05;
    cola = rph * 0.04;
    npay = bspc - (tax + sss + pagibig);
    gpay = npay + cola + bonus;
    
    if(gpay <= 7500)
      el = 1;
    else if(gpay > 7500 && gpay < 10000)
      el = 2;
    else if(gpay >= 10000 && gpay < 15000)
      el = 3;
    else if(gpay >= 15000 && gpay < 17500)
      el = 4;
    else if(gpay >= 17500 && gpay < 20000)
      el = 5;
    else if(gpay >= 20000 && gpay < 22500)
      el = 6;
    else if(gpay >= 22500 && gpay < 25000)
      el = 7;
    else if(gpay >= 25000 && gpay < 27500)
      el = 8;
    else if(gpay >= 27500 && gpay < 30000)
      el = 9;
    else
      el = 10;
    
    
    clrscr();
    printf("DEDUCTIONS\n");
    printf("Tax: %.2f", tax);
    printf("\nSSS: 250");
    printf("\nPag-ibig: 150");
    
    printf("\n\nADDITIONAL SALARY");
    printf("\nOvertime Pay: %.2f", otp);
    printf("\nCost of Living Allowance: %.2f", cola);
    
    printf("\n\nBasic Salary per cut-off: %.2f", bspc);
    printf("\nNetpay: %.2f", npay);
    printf("\nGrosspay: %.2f", gpay);
    printf("\nEmployee Level: %i", el);
    
    
    
    getch();
    return 0;
    }

  4. #19
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by smalhumble View Post
    is this correct? help
    Gee... isn't that for your teacher to say?

    Do you have specific questions or are you just seeking our approval?

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Code:
    scanf("%int",&nhw);
    Legal, but unlikely.

    Code:
    while(ndw > 12);
    Infinite loop.

  6. #21
    Registered User
    Join Date
    Aug 2011
    Posts
    7
    sir tabstop, so what will i do, remove the while ?

  7. #22
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    This is your code:
    Code:
    {.....
      if(ndw > 12)
      {
        printf("\nEnter upto 12 no. of days worked only.");
        getch();
      }
    }while(ndw > 12);
    What do you think you should do? Note: You aren't using a do-while loop here. I am not even sure what you think you are doing here. The compiler sees this:
    while(ndw>12); <--That is the whole loop. Thus if you ever have ndw>12 there is no way for the loop to terminate.
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

  8. #23
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by smalhumble View Post
    sir tabstop, so what will i do, remove the while ?
    I'd suggest the first thing you do is to compile and run your code so that YOU can see what's wrong with it!

  9. #24
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    I suggest learning to indent your code.

    Code:
    Enter Rate per Hour: 2
    Enter No. of Hours Worked: 4
    Enter No. of Days Worked: 3
    DEDUCTIONS
    Tax: 0.80
    SSS: 250
    Pag-ibig: 150
    
    ADDITIONAL SALARY
    Overtime Pay: -12.00
    Cost of Living Allowance: 0.08
    
    Basic Salary per cut-off: 24.00
    Netpay: -376.80
    Grosspay: -375.52
    Employee Level: 1
    I see part time workers are really not a common thing in your testing.

    Tim S.

  10. #25
    Registered User
    Join Date
    Aug 2011
    Posts
    7
    sir common, i had already run that. and its running. no error.

  11. #26
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by smalhumble View Post
    sir common, i had already run that. and its running. no error.
    What happens when you put in 14 days worked?

  12. #27
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by smalhumble View Post
    sir common, i had already run that. and its running. no error.
    You appeared to be trying writing a "do while" loop; but, you forgot something.

    Tim S.

  13. #28
    Registered User
    Join Date
    Jul 2011
    Posts
    14
    DO while loop :P

    and think of what you're checking for looping condition and where your loop starts and ends.
    LOL. We love saying the same things, don't we xD

  14. #29
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Code:
    Enter Rate per Hour: 12
    Enter No. of Hours Worked: 8
    Enter No. of Days Worked: 1
    DEDUCTIONS
    Tax: 9.60
    SSS: 250
    Pag-ibig: 150
    
    ADDITIONAL SALARY
    Overtime Pay: 0.00
    Cost of Living Allowance: 0.48
    
    Basic Salary per cut-off: 96.00
    Netpay: -313.60
    Grosspay: -308.32
    Employee Level: 1
    Remind me to never get a job in India; the pay is terrible.
    You must have to work overtime just to break even.

    Tim S.

  15. #30
    Registered User
    Join Date
    May 2011
    Location
    Around 8.3 light-minutes from the Sun
    Posts
    1,949
    Additionally,

    1. getch() is compiler specific, use something guaranteed by the standard such as getchar();
    2. implicit main() is wrong. Read How to define main() - FAQ.
    3. Get a new compiler. Read Why Turbo C is bad
    4. For the last time learn to indent! Read How to indent
    Quote Originally Posted by anduril462 View Post
    Now, please, for the love of all things good and holy, think about what you're doing! Don't just run around willy-nilly, coding like a drunk two-year-old....
    Quote Originally Posted by quzah View Post
    ..... Just don't be surprised when I say you aren't using standard C anymore, and as such,are off in your own little universe that I will completely disregard.
    Warning: Some or all of my posted code may be non-standard and as such should not be used and in no case looked at.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help converting array program to link list program
    By hsmith1976 in forum C++ Programming
    Replies: 0
    Last Post: 02-14-2010, 09:50 PM
  2. Replies: 1
    Last Post: 03-03-2009, 04:47 PM
  3. Get program to copy itself into program files, then start on startup.
    By guitarist809 in forum Windows Programming
    Replies: 6
    Last Post: 03-03-2008, 09:42 AM
  4. Replies: 5
    Last Post: 08-16-2007, 11:43 PM
  5. Replies: 18
    Last Post: 11-13-2006, 01:11 PM