Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7401221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:24:32+00:00 2026-05-29T04:24:32+00:00

Well I’m making an program about payrolls and I’m stuck. In the program, after

  • 0

Well I’m making an program about payrolls and I’m stuck. In the program, after the user has entered the number of employees, I have to make an loop, allowing the user to enter information for each of the employees. Then the data entered is to be stored in my employees array, which I made. Ive attempted my problem with the while(numberOfEmployees < MAXSIZE) part of my program. Is that right?

This is what I have now:

#include <iostream>
using namespace std;

const int MAXSIZE = 20;

struct EmployeeT
{
    char name[MAXSIZE];
    char title;
    double gross;
    double tax;
    double net;
};

EmployeeT employees[MAXSIZE];

int main()
{
    cout << "How many Employees? ";
    int numberOfEmployees;
    cin >> numberOfEmployees;

    while(numberOfEmployees > MAXSIZE)
    {
        cout << "Error: Maximum number of employees is 20\n";
        cout << "How many Employees? ";
        cin >> numberOfEmployees;
    }

    int name;
    int title;
    double gross;
    double tax;
    double net;

    for (int count=0; count<numberOfEmployees; count++)
    {
        cout << "Name: \n";
        cin >> employees[ count ].name;

        cout << "Title: \n";
        cin >> employees[ count ].title;

        cout << "Gross: \n";
        cin >> employees[ count ].gross;

        cout << "Tax: \n";
        cin >> employees[ count ].tax;

        cout << "Net: ";
        cin >> employees[ count ].net;
    }
}

I just updated it to this. My last question is how do I get the second loop to keep working as many times as the user wants. For as many employees the user types in?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T04:24:33+00:00Added an answer on May 29, 2026 at 4:24 am

    Several problems:

    1- Place a i++ somewhere inside the while loop
    (Why not use a for loop?)

    2- name and title should probably be a string:

    #include <string>
    //in the main:
    std:string name;
    

    3- the while condition should be:

    while(i<numberOfEmployees && i<MAXSIZE)
    

    (Edit: I see you just corrected that one)

    Edit: I just noticed you always write to the same variables. Write to employees[i].name etc. instead.

    Does that solve your problem?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well after much messing about I have finally got a query that gives sales
Well, I have this bit of code that is slowing down the program hugely
Well i have var message , which has any type of character... I replace
Well, after a long time writing .net programs in C# I started to feel
Well, this is my first post here and really enjoying the site. I have
Well this is incredibly frustrating. After being nagged by Rails that I need to
well i have this messages table with sample values like these: msg_id recipient_id read
Well, i have the following need: create 3 dropdownlist with dependencies. My table in
Well my windows service has to send out automated emails when the sql database
well i have used an html file like these in iframe <iframe src=sample.html></iframe> is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.