Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

I need help, I'm still a newbie and a beginner in the programming world. 

 

 

Spoiler

#include<stdio.h>
#include<conio.h>
    int main()
{
    int en,hw,num=0,n=0;
    int rh,rd,gi,ss,ot,pi,pg,td,ni,r,R,P,p,C,T,c,t,S,s,m,M,oh,ba;

    for(num=0;num<=0;num++)
    {
        char answer[15],es,cs;
        printf("ENTER YOUR EMPLOYEE ID NUMBER:  \n");
        scanf("%d", &en);
        printf("ENTER YOUR EMPLOYMENT STATUS: \n");
        scanf("%s",&es);
        printf("ENTER YOUR CIVIL STATUS: \n");
        scanf("%s",&cs);
        printf("ENTER YOUR HOURS WORK: \n");
        scanf("%d",&hw);
        printf("\n");
        printf("\n");
        for(n=0;n<=num;n++)
        {
            if(es)
            {
                if(es=='r||R')
                {
                    es=800;
                }
                else if(es=='p||P')
                {
                    es=600;
                }
                else if(es=='c||C')
                {
                    es=500;
                }
                else if(es=='t||T')
                {
                    es=450;
                }
                else{
                    es=400;
                }
            }
            
                rh=es/8;
                
                            if(hw)
                            {
                                if(hw<120)
                                {
                                    oh=hw-120;
                                    ot=1.5*(rh*oh);
                                }
                                else{
                                    ba=hw*rh;
                                }
                            }
                                gi=ba+ot;
                                
                                if(gi<0)
                                {
                                    if(gi<=10000)
                                    {
                                        ss=0.1;
                                    }
                                    else(gi<=5000);
                                        ss=0.08;
                                }
                                
                                    if(pi)
                                        {
                                            if(pi=='s||S')
                                            {
                                                pi=500;
                                            }
                                            else if(pi=='m||M')
                                            {
                                                pi=300;
                                            }
                                            else{
                                                pi=400;
                                            }
                                        }
                                        
                                            if(gi<0)
                                            {
                                                if(gi<=10000)
                                                {
                                                    pg=0.05;
                                                }
                                                else if(gi<=5000)
                                                {
                                                    pg=0.03;
                                                }
                                                else
                                                {
                                                    pg=0.02;
                                                }
                                            }
                                            
                                                    td=ss+pi+pg;
                                                    ni=gi-td;
                                                    
                                            printf("EMPLOYEE NUMBER:%d\n",en);
                                            printf("HOURS WORK:%d\n",hw);
                                            printf("EMPLOYMENT STATUS:%c\n",es);
                                            printf("CIVIL STATUS:%c\n",cs);
                                            printf("RATE PER HOUR:%d\n",rh);
                                            printf("GROSS INCOME:%d\n",gi);
                                            printf("SSS:%d\n",ss);
                                            printf("PHILHEALTH:%d\n",pi);
                                            printf("PAG-IBIG:%d\n",pg);
                                            printf("TOTAL DEDUCTION:%d\n",td);
                                            printf("NET INCOME:%d\n",ni);
        } 
    }
                        printf("DO YOU WANT TO COMPUTE ANOTHER ONE?:(y or n)\n");
    return 0;
}

 

Link to post
Share on other sites

Well for starts you should explain what you are trying to do.
And maybe for niceness put current result and expected result as well.

Help us help you buddy, we know NOTHING! if you dont tell us. ;)

When i ask for more specs, don't expect me to know the answer!
I'm just helping YOU to help YOURSELF!
(The more info you give the easier it is for others to help you out!)

Link to post
Share on other sites
1 minute ago, HanZie82 said:

Well for starts you should explain what you are trying to do.
And maybe for niceness put current result and expected result as well.

Help us help you buddy, we know NOTHING! if you dont tell us. ;)

 

Yeah its in a big blue/green bar on top. like WTF!!!

Also, I'm no programmer, but isn't using a fuck ton of if/else extremely inefficient?

Quote me to see my reply!

SPECS:

CPU: Xeon X5650 OC'd to 4.2GHz @ 1.35V (courtesy of @XR6)Motherboard: Asus Sabertooth X58 RAM: 4x4GB G.Skill DDR3 1866MHz GPU: Asus RX 570 Strix Storage: WD Blue 1TB and a 128GB Kingston UV400 PSU: EVGA 600B Case: Fractal Design Define C Cooling: H100i V2, be quiet! Pure Wings 2 (two intake, two exhausting through radiator) Monitor: 3x Dell P2210 on a Steelcase Eyesite triple monitor stand Mouse: Logitech G403 Prodigy Wireless Keyboard: It changes, but usually Focus FK-9000 Mousepad: Steelseries QcK XL Headphones:  Sennheiser HD598SE

 

 

 

 

i use arch btw

Link to post
Share on other sites
3 minutes ago, kelvinhall05 said:

Also, I'm no programmer, but isn't using a fuck ton of if/else extremely inefficient?

Logic would say yes, but im also no programmer, per sé.

When i ask for more specs, don't expect me to know the answer!
I'm just helping YOU to help YOURSELF!
(The more info you give the easier it is for others to help you out!)

Link to post
Share on other sites

-Edited-

Please use code tags when posting programs - and a spoiler if its on the longer side.

Community Standards || Tech News Posting Guidelines

---======================================================================---

CPU: R5 3600 || GPU: GTX 1080 || Memory: 16GB @ 3200 || Cooler: Noctua D15 || PSU: 750W EVGA G2 || Case: Define C

Link to post
Share on other sites
Just now, kelvinhall05 said:

Also, I'm no programmer, but isn't using a fuck ton of if/else extremely inefficient?

Yes, it is. It looks like most/all of these are equality of int or char types, so they would be better implemented as switch statements. (The inequalities (that's <, <=, >, or >= ) need to be if/else's still.)

 

And a few other notes, OP: short variable names don't make your code more efficient. Help us, and yourself, with some real names (i.e. use employment_status or employmentStatus rather than es). I don't have any idea what gi, ba, ot, etc, mean, and if you set this down and come back to it in two weeks, you probably won't, either.

 

Statements like if(es=='r||R') don't work the way you want it to; in fact, it won't even compile. Use if(toUpper(es)=='R') instead (though, as above, switch(toUpper(es)) is even better).

 

Also, for user-friendliness, sentence-case your outputs so we don't feel like your program is screaming at us. :)

 

That's about all the help I can give without more specific questions.

Link to post
Share on other sites
5 minutes ago, fordy_rounds said:

Yes, it is. It looks like most/all of these are equality of int or char types, so they would be better implemented as switch statements. (The inequalities (that's <, <=, >, or >= ) need to be if/else's still.)

 

And a few other notes, OP: short variable names don't make your code more efficient. Help us, and yourself, with some real names (i.e. use employment_status or employmentStatus rather than es). I don't have any idea what gi, ba, ot, etc, mean, and if you set this down and come back to it in two weeks, you probably won't, either.

 

Statements like if(es=='r||R') don't work the way you want it to; in fact, it won't even compile. Use if(toUpper(es)=='R') instead (though, as above, switch(toUpper(es)) is even better).

 

Also, for user-friendliness, sentence-case your outputs so we don't feel like your program is screaming at us. :)

 

That's about all the help I can give without more specific questions.

thank you for the tip and sorry i used uppercase in my program. I'm trying my best to understand and learn programming in C.

Link to post
Share on other sites
2 minutes ago, REDRIDINGHOODS said:

thank you for the tip and sorry i used uppercase in my program. I'm trying my best to understand and learn programming in C.

Walang anuman. We all started somewhere. Good luck with your learning!

Link to post
Share on other sites
12 minutes ago, fordy_rounds said:

Walang anuman. We all started somewhere. Good luck with your learning!

Salamat sa motivation.

Link to post
Share on other sites
6 hours ago, REDRIDINGHOODS said:

thank you for the tip and sorry i used uppercase in my program. I'm trying my best to understand and learn programming in C.

Don´t worry about too many if statements. All that matters it that it works. 

 

6 hours ago, kelvinhall05 said:

Also, I'm no programmer, but isn't using a fuck ton of if/else extremely inefficient?

It remindend

6 hours ago, fordy_rounds said:

Yes, it is.

Yes, it is slightly slower but generally speaking, doesn´t matter compared to other inefficiencies. Compilers also got pretty good nowadays at optimizing code.

 

It reminded me of the following developers screenshot from the game Star Citizen. It shows nine nested if loops. Sorry for the bad quality but I did not make it:

 

4vtfz2yhwsg41.png.f3fb5e73a45f8e4873c2cd22a4e5e849.png

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×