Objectives:

To     write     program     with     input,     output     and     control     structures:     sequential,     selection    

and        

 

loop    

To    write    program    using    array.    

 

Question:    

    

Write    a    program    that    creates    two    String    arrays,    one    to    store    names    of    5    boys    and    another    to        

store    names    of    5    girls.    Read    the    names    from    the    user.        The    program    then    matches    the    boys        

and    the    girls    randomly    and    displays    the    5    pairs    of    matched    couples.        The    user    can    repeat    the        

same    process    of    randomly    matching    the    5    pairs    until    (s)he    chooses    to    quit    the    program.    

 

Your    program    should    not    repeat    any    boy’s    or    girl’s    name    in    the    matching    ͘

 

 

The    sample    of    input    and    output    of    the    program    is    shown    below:    

This    program    is    used    to    randomly    match    boys    and    girls    

**********************************************    

    

Please    enter    the    names    of    5    boys:    

Jonathan    

Billy    

Steven        

William        

George    

    

Please     enter     the     names     of     5     girls:        

Mandy    

Ellie    

Lauren        

Alice    

Camilla    

 

The     result     of     the     matching:    

Steven    and    Alice    

Jonathan     and     Camilla    

Billy    and    Ellie    

William     and     Mandy        

George    and    Lauren    

    

Do    you    want    to    re-­‐match?    (y/n):    y    

    


The     result     of     the     matching:    

Billy    and    Camilla    

George     and     Mandy        

Jonathan     and     Alice        

William     and     Lauren        

Steven    and    Ellie    

 

Do     you     want     to     re-­‐match?     (y/n):     n        

 

 

Thank    you    for    using    the    program.   

    • 12 years ago
    Change Name Match
    NOT RATED

    Purchase the answer to view it

    blurred-text
    • attachment
      change_name_match.java