Note that there are some explanatory texts on larger screens.

plurals
  1. POAsking user for info in loop: how to keep working as many times as the user wants?
    primarykey
    data
    text
    <p>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 <code>while(numberOfEmployees &lt; MAXSIZE)</code> part of my program. Is that right?</p> <p>This is what I have now:</p> <pre><code>#include &lt;iostream&gt; 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 &lt;&lt; "How many Employees? "; int numberOfEmployees; cin &gt;&gt; numberOfEmployees; while(numberOfEmployees &gt; MAXSIZE) { cout &lt;&lt; "Error: Maximum number of employees is 20\n"; cout &lt;&lt; "How many Employees? "; cin &gt;&gt; numberOfEmployees; } int name; int title; double gross; double tax; double net; for (int count=0; count&lt;numberOfEmployees; count++) { cout &lt;&lt; "Name: \n"; cin &gt;&gt; employees[ count ].name; cout &lt;&lt; "Title: \n"; cin &gt;&gt; employees[ count ].title; cout &lt;&lt; "Gross: \n"; cin &gt;&gt; employees[ count ].gross; cout &lt;&lt; "Tax: \n"; cin &gt;&gt; employees[ count ].tax; cout &lt;&lt; "Net: "; cin &gt;&gt; employees[ count ].net; } } </code></pre> <p>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?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload