Someone help please?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 15

Thread: Someone help please?

  1. #1
    Join Date
    Feb 2009
    Posts
    10

    Someone help please?

    I am new to programming and I am having problems doing this. Can anyone pm me the solution to this? I want to compare mine to another persons. Thanks.

    "Develop an algorithm that will determine the gross pay of a particular employee. You need to read the hourly rate, and the amount of hours worked by the employee. You should display the hours, hourly rate, and gross pay of the employee. If the hours worked exceed 40 compute the overtime will be paid 1.5 *hourly rate."

  2. #2
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,026

    Re: Someone help please?

    Unfortunately, my little son 11 yrears old, is not home now to solve your problem.
    However, you can take a look at Can you help me with my homework assignment?
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  3. #3
    Join Date
    Nov 2003
    Location
    Belgium
    Posts
    8,062

    Re: Someone help please?

    You want to compare yours to ours....
    So, why don't you post your solution and we can give you feedback on it?

  4. #4
    Join Date
    Feb 2009
    Posts
    10

    Re: Someone help please?

    ......
    Last edited by nubcoder01; February 15th, 2009 at 08:59 PM.

  5. #5
    VictorN's Avatar
    VictorN is online now Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,418

    Re: Someone help please?

    1. Please, always use Code tags while posting code snippets. See Announcement: Before you post....
    2. Your code cannot be compiled. What are hours, rate, hrsworked , overtime, overtimerate, Grosspay2, hourlyrate, grosspay2? Where and how are they defined?
    Victor Nijegorodov

  6. #6
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Someone help please?

    Also... code is case sensitive.

  7. #7
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,106

    Re: Someone help please?

    Quote Originally Posted by nubcoder01 View Post
    I am new to programming and I am having problems doing this. Can anyone pm me the solution to this? I want to compare mine to another persons. Thanks.
    It's a mistake to come in here an insult our intelligence.

  8. #8
    Join Date
    Feb 2009
    Posts
    10

    Re: Someone help please?

    Sorry guys, it's just I'm really new to this stuff. My teacher literally handed me this book called "C Primer Plus 5th edition" and told me to this assignment. I am so clueless. Any advice is appreciated. Where to start? Am I even on the right track? Help!?!?

  9. #9
    Join Date
    Feb 2009
    Posts
    10

    Re: Someone help please?

    .....
    Last edited by nubcoder01; February 15th, 2009 at 08:50 PM.

  10. #10
    Join Date
    Apr 1999
    Posts
    27,429

    Re: Someone help please?

    Quote Originally Posted by nubcoder01 View Post
    Can anyone at least help me on where/how I should start this?
    Code:
    int main()
    {
       // fill this in 
    }
    Honestly I am not even sure where to start.....what I posted before is just a bunch of random things that really don't make much sense to me.
    So what do you want us to do? I'll give you a test:

    Write a C++ "Hello World" program.

    If you can't do this properly, then it's futile asking for help with this problem you're having. From what you've written, you shouldn't be able to write a proper "Hello World" C++ program, since there are so many basic beginner errors in the code you posted.

    I suggest you read your book from chapter 1 until you understand everything in chapter 1.

    Regards,

    Paul McKenzie

  11. #11
    Join Date
    Feb 2009
    Posts
    10

    Re: Someone help please?

    Quote Originally Posted by Paul McKenzie View Post
    Code:
    int main()
    {
       // fill this in 
    }
    So what do you want us to do? I'll give you a test:

    Write a C++ "Hello World" program.

    If you can't do this properly, then it's futile asking for help with this problem you're having. From what you've written, you shouldn't be able to write a proper "Hello World" C++ program, since there are so many basic beginner errors in the code you posted.

    I suggest you read your book from chapter 1 until you understand everything in chapter 1.

    Regards,

    Paul McKenzie
    Here:

    #include <stdio.h>
    #include <stdlib.h>

    main(){
    printf("Hello World! \n");
    }

  12. #12
    Join Date
    Feb 2009
    Posts
    10

    Re: Someone help please?

    What's wrong with this? It is not compiling.......

    #include <stdio.h>
    #include <stdlib.h>
    main(){
    double hours, rate, grosspay, overtimepay;
    printf("Hours:\n");
    scanf("&#37;lf", &hours);
    printf("Rate:\n");
    scanf("%lf", &rate);

    if(hours>40)
    overtimepay = 40 * rate + (hours - 40) * rate * 1.5;
    printf("Over time pay = %lf\n", overtimepay);

    else
    grosspay = hours * rate;
    printf("Grosspay = %lf\n", grosspay);


    system("pause");
    Last edited by nubcoder01; February 15th, 2009 at 09:12 PM.

  13. #13
    Join Date
    Apr 1999
    Posts
    27,429

    Re: Someone help please?

    Quote Originally Posted by nubcoder01 View Post
    Here:

    #include <stdio.h>
    #include <stdlib.h>

    main(){
    printf("Hello World! \n");
    }
    No. This is not a correct C++ "Hello World" program.
    Code:
    Thank you for testing your code with Comeau C/C++!
    Tell others about http://www.comeaucomputing.com/tryitout !
    
    Your Comeau C/C++ test results are as follows:
    
    Comeau C/C++ 4.3.10.1 (Oct  6 2008 11:28:09) for ONLINE_EVALUATION_BETA2
    Copyright 1988-2008 Comeau Computing.  All rights reserved.
    MODE:strict errors C++ C++0x_extensions
    
    "ComeauTest.c", line 4: error: return type "int" omitted in declaration of function
              "main", so use int main() OR int main(int argc, char *argv[])
      main(){
      ^
    
    1 error detected in the compilation of "ComeauTest.c".
    
    In strict mode, with -tused, Compile failed
    The following is a correct C++ "Hello World" program:
    Code:
    #include <iostream>
    
    int main()
    {   
       std::cout << "Hello World";
    }
    See the difference?

    Also, are you coding in 'C' or C++. If it's 'C' please say so.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; February 15th, 2009 at 09:48 PM.

  14. #14
    Join Date
    Apr 1999
    Posts
    27,429

    Re: Someone help please?

    At the very least, list the compiler errors. The first error is obvious, as my last post shows. Also, please use code tags when posting code. See how the code I post is formatted nicely, and yours is ragged? The magic of code tags makes the code readable.

    Regards,

    Paul McKenzie
    Last edited by Paul McKenzie; February 15th, 2009 at 09:47 PM.

  15. #15
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Someone help please?

    What's wrong with this? It is not compiling.......
    You if/else statement is missing {}. Check MSDN on how to use if/else.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center