Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,083 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,523 people online right now. Registration is fast and FREE... Join Now!




please help

 
Closed TopicStart new topic

please help

c++izhere
21 Apr, 2008 - 07:57 PM
Post #1

New D.I.C Head
*

Joined: 12 Mar, 2007
Posts: 41


My Contributions
write a c++ program to read an unspecified number of input records. each input record will contain a code and a person's age. a code of 1 will indicate female; a code of 2 will indicate male; and a code of 0 will indicate end of input(exit code). Any other code is invalid and must display an appropriate error message. continue accepting and processing input records until the exit code is enter. Finally compute and display the following:
1. number of males 21 years old or older.
2. Number of females 21 years old or older.
3.Average age of all persons under 21.
4.total number of people


CODE
                                                                                    
#inlcude<iostream>

int main()
{
int age, code, m_age1, male2, f_age1, f_age2
  count=0,max;

            std::cout<<" Input code and Age or press 0 to exit and press <Enter>" <<std::endl
    
     while(code !=0)
      {
        

        std::cin>>code, age;
        }

     if(m_age>=21)
       {
      m_age1=m_age1+m_total
      m_total=m_total+m_age1

        std::cout<< m_total<<std::endl;

        else if (f_age>=21)
            
         f_age1=f_age1+f_total
         f_total=f_total+f_age1
      

         std::cout<< f_total/ f_age1<<std::endl;

        else

         f_age2=f_age2+f_total2
         f_total2=f_total+f_age2

          std::cout<<f_total2<<std::endl;
         }

          std::cout<< m_age2+f_age2 <<std::endl;
          std::cout<< f_total + m_total <<std::endl;
}
     return 0;
}
  

User is offlineProfile CardPM
+Quote Post

Closed TopicStart new topic
Time is now: 12/1/08 07:50PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month