Answer to Question #198357 in C++ for Blessing

Question #198357

You Just got your 1st internship as C++ developer CONGRATULATIONS, your manager gives you your 1st task to solve below.PROBLEM SPECIFICATION

Your company wants to collect the total number of age groups within the company and calculate the average age of employees and the classification (see below table) within the company. You are required to write a program in C++ that will ask the user to enter the integer age. Determine in which group allocation each employee belong (refer to table below) and calculate the total Age sum and the company average age. The program should populate areport showing all the information The user should enter a negative value to indicate that they are done Description Young employees Age group From 19 till 35 Middle Age group Elderly 36 till 49 (inclusive) 50 till 65


1
Expert's answer
2021-05-25T14:10:09-0400


#include <iostream>


using namespace std;


int main()
{
    int age;
    int i=1;
    int empAges[100];
    while (true){
       cout<<"\nEnter your age: ";
       cin>>age;
       empAges[i-1]=age;
        if (age>=19 && age<35){
           cout<<"\n"<<age <<" is young age";
       }
       else if (age>=36 && age<=49){
           cout<<"\n"<<age <<" is middle age";
       }
       else if (age>=50 && age<=65){
           cout<<"\n"<<age <<" is eldery age ";
       }
       if (age<0){
           break;
       }
       i++;
    }
    cout<<i;
    int sumAges=0;
    for (int j=0;j<i-1;j++)
    {
       sumAges=sumAges+empAges[j];
    }
    cout<<"\nSum of ages = "<<sumAges;
    cout<<"\nAverage age = "<<sumAges/i;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog