Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1

    Default help plss for my assignment


    mga kua's pa help nmn ko ani nag lisud jud ko ani.. kani ang ako problem

    group 1 males under 25 years old
    group 2 females "' " " "
    group 3 males between 25-45" "
    group 4 females " "
    group 5 all people are 45years old

    design a program to input a necessry information for a person and output his/her group

    #include<stdio.h>void main ()
    {
    int AGE;
    char G;
    printf("\n\nGender Male [M/m] - Female [F/f]: ");
    scanf("%s",&G);
    printf("\n\nAge: ");
    scanf("%d",&AGE);
    if ((G=='M' || G=='m') || (G=='F' || G=='f') )
    if(AGE<25)

    printf("\n\n\nGroup 1\n\n\n");
    else if( G=='F' || G=='f')
    printf("\n\n\nGroup 2\n\n\n");


    else
    if ((G=='M' || G=='m') || (G=='F' || G=='f') )
    if(25>45)
    printf("\n\n\nGroup 3\n\n\n");
    else
    if( G=='F' || G=='f')

    printf("\n\n\nGroup 4\n\n\n");

    }
    mao na ako gi code murag sayup man kay inig input nako sa f dili siya mo group 2 hahaiz tabang plss

  2. #2
    C.I.A. Platinum Member carmicael's Avatar
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    2,142

    Default Re: help plss for my assignment

    naay something wrong sa imong condition.
    use braces para ma group ug tarong imong conditions, para di ka mag libog.

    refer to this segment:
    Code:
    if ((G=='M' || G=='m') || (G=='F' || G=='f') )
        if(AGE<25) 
            printf("\n\n\nGroup 1\n\n\n");
        else if( G=='F' || G=='f') 
            printf("\n\n\nGroup 2\n\n\n");
    *if musulod siya sa first condition, then no sense na mag "else if" pa ka ug (G=='F'....
    *ang expected output ani imong gi-provide na code kay:
    -> m, < 25 : "Group 1" is printed
    -> m, 25 + : nothing happens
    -> f, < 25 : "Group 1" is printed
    -> f, 25 + : "Group 2" is printed

  3. #3

    Default Re: help plss for my assignment

    lagi mao nay mugawas ganiha ra jud ko gahunahuna unsaon . ahm give me more some idea plss

  4. #4

    Default Re: help plss for my assignment

    kid... sunod bah paminaw sa imong maestro then if lisoran ka do a research .... and ask MR. google.. unsay gamit sa internet......

  5. #5
    C.I.A. Platinum Member carmicael's Avatar
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    2,142

    Default Re: help plss for my assignment

    Quote Originally Posted by kronouzgg View Post
    lagi mao nay mugawas ganiha ra jud ko gahunahuna unsaon . ahm give me more some idea plss
    naa kay 4 ka categories, therefore, at most, 4 ka conditions ang imo kelangan. naa kay Male, less than 25yo; Male, 25yo or older; Female, less than 25yo; Female, 25yo or older. mao na ang imong 4 conditions.

    Code:
    if(Male and less than 25yo)
       do something 1
    else if(Male and 25yo or older)
       do something 2
    else if(Female and less than 25yo)
       do something 3
    else
       do something 4
    you need not complicate things further like sa imong code, na daghan pa kaayo nested if-conditions.

    naa diay cheat code, pero ayaw basaha until wa pa ka naka solve sa imong problem. (temptations...)
    Spoiler! 

    ayaw sa lage.

  6. #6

    Default Re: help plss for my assignment

    sige idol wla pa nako gi ablihan.. ako sa ni e solve di ko mag salig sa cheat .. gusto jud ko makat on og mayo .. kya need sad nako og idea ninyo kay di man nako makaya

  7. #7
    C.I.A. Platinum Member carmicael's Avatar
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    2,142

    Default Re: help plss for my assignment

    mao na to ang kina simple na solution. 4 ka conditions. ang pseudocode sa ako previous post, i-convert to C. mao na to ang hint. unsa na hint pa imo gipangita?

  8. #8

    Default Re: help plss for my assignment

    idol mao na ni nakuha na ba nako? pls inform me kung sakto na


    #include<stdio.h>
    void main ()
    {
    int AGE;
    char G;
    printf("\n\nGender Male [M/m] - Female [F/f]: ");
    scanf("%s",&G);
    printf(\n\nAge: ");
    scanf("%d",&AGE);
    if ((G=='M' || G=='m') && (AGE<25))

    printf("\n\n\nGroup 1\n\n\n");
    else
    if((G=='F' || G=='f') && (AGE<25) )
    printf("\n\n\nGroup 2\n\n\n");

    else if((G=='M' || G=='m') && (25<45))

    printf("\n\n\nGroup 3\n\n\n");

    else if((G=='F' || G=='f') && (25<45))
    printf("\n\n\nGroup 4\n\n\n");

    }

  9. #9
    C.I.A. Platinum Member carmicael's Avatar
    Join Date
    Jul 2007
    Gender
    Male
    Posts
    2,142

    Default Re: help plss for my assignment

    Quote Originally Posted by kronouzgg View Post
    idol mao na ni nakuha na ba nako? pls inform me kung sakto na
    medyo ok na ang hitsura, pero sayop imong duha ka last conditions. always mu true ang result sa "(25 < 45)" ang dapat ana kay "(AGE>=25)".

    kani pod:
    Code:
    printf(\n\nAge: ");
    kulang opening quotation marks.



    anyway, congratulations. ok na imong program.
    as promised, mao ni akong solution:
    Spoiler! 

    Code:
    #include <stdio.h>
    
    void main(void) {
        int AGE;
        char G;
    
        printf("\n\nGender Male [M/m] - Female [F/f]: ");
        scanf("%s", &G);
    	
        if(toupper(G) != 77 && toupper(G) != 70)
            return;
    
        printf("\n\nAge: ");
        scanf("%d", &AGE);
    	
        if(AGE < 0)
            return;
    
        printf("\n\n\nGroup %d\n\n\n", (((AGE < 25) ? 1 : 5) + 
    	    (((toupper(G)) == 77) ? 1 : 3)) / 2);
    }

  10. #10

    Default Re: help plss for my assignment

    yes kuha na jud nako tanan bali master mao nani ang ako final answer ,, lisuda sabtun sa imoha code wew advanced kayo .. di ko kasabut ako sad gi try di siya mu run .. pero thanks kayo master sa idea

    #include<stdio.h>
    void main ()
    {
    int AGE;
    char G;
    printf("\n\nGender Male [M/m] - Female [F/f]: ");
    scanf("%s",&G);
    printf("\n\nAge: ");
    scanf("%d",&AGE);
    if ((G=='M' || G=='m') && (AGE<25))

    printf("\n\n\nGroup 1\n\n\n");
    else if((G=='F' || G=='f') && (AGE<25) )
    printf("\n\n\nGroup 2\n\n\n");

    else if((G=='M' || G=='m') && (AGE<=45))

    printf("\n\n\nGroup 3\n\n\n");

    else if((G=='F' || G=='f') && (AGE<=45))
    printf("\n\n\nGroup 4\n\n\n");

    else if((G=='F' || G=='f') && (AGE>45))
    printf("\n\n\nGroup 5\n\n");
    else if((G=='M' || G=='m') && (AGE>45))
    printf("\n\n\nGroup 5\n\n");

    }

  11.    Advertisement

Page 1 of 2 12 LastLast

Similar Threads

 
  1. Help--Monitor for my Loptop
    By namoku in forum Computer Hardware
    Replies: 4
    Last Post: 07-13-2011, 07:53 PM
  2. help me for my nokia phone
    By John David in forum General Discussions
    Replies: 4
    Last Post: 01-14-2011, 08:43 AM
  3. Help Gift for my 1yr old baby girl niece^^
    By gsirk in forum "Love is..."
    Replies: 0
    Last Post: 10-22-2010, 02:33 AM
  4. HELP Falling for my bestfriend
    By hayden_ko in forum Relationships (Old)
    Replies: 102
    Last Post: 06-12-2009, 12:29 PM
  5. Help! Vote for my design
    By dulcepixels in forum Websites & Multimedia
    Replies: 34
    Last Post: 07-06-2008, 02:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top