Note that there are some explanatory texts on larger screens.

plurals
  1. POSolution for printing information to the screen in c++?
    primarykey
    data
    text
    <p>I have to make a loop to gather all the information from the users input of the employees. As you can see, I have gotten the parts where I ask the user how many employees and what their information is. Now all I have to is print that information to the screen like this, just without the periods between each and with a few spaces between each :</p> <pre><code>Weekly Payroll: Name...............Title........Gross.......Tax.........Net ---------------------------------------- Ebenezer Scrooge.....................Partner...250.00......62.25.....187.75 Bob Cratchit...............................Clerk.......15.00........2.00.......13.00 </code></pre> <p>And this is what I have :</p> <pre><code>#include &lt;iostream&gt; using namespace std; const int MAXSIZE = 20; struct EmployeeT { char name[MAXSIZE]; char title; double SSNum; double Salary; double Withholding_Exemptions; }; 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; } char name[MAXSIZE]; int title; double SSNum; double Salary; double Withholding_Exemptions; for (int count=0; count &lt; numberOfEmployees; count++) { cout &lt;&lt; "Name: "; cin &gt;&gt; employees[ count ].name; cout &lt;&lt; "Title: "; cin &gt;&gt; employees[ count ].title; cout &lt;&lt; "SSNum: \n"; cin &gt;&gt; employees[ count ].SSNum; cout &lt;&lt; "Salary: \n"; cin &gt;&gt; employees[ count ].Salary; cout &lt;&lt; "Withholding Exemptions: \n"; cin &gt;&gt; employees[ count ].Withholding_Exemptions; } double gross; double tax; double net; double adjusted_income; gross = employees[ count ].Salary; adjusted_income = employees[ count ].Salary - 1.00; tax = adjusted_income * .25; net = gross - tax; cout &lt;&lt; "Weekly Payroll:\t Name \t Title \t Gross \t Tax \t Net \n"; for (int count=0; count &lt; numberOfEmployees; count++) { cout &lt;&lt; employees[count].name &lt;&lt; " \t" &lt;&lt; employees[count].title &lt;&lt; " \t" &lt;&lt; gross &lt;&lt; "\t" &lt;&lt; tax &lt;&lt; "\t" &lt;&lt; net &lt;&lt; "\n"; } system("pause"); </code></pre> <p>} </p> <p>Ok I updated the program. Now I'm trying to do the calculations. This what I'm doing...</p> <blockquote> <p>To calculate payroll: </p> </blockquote> <p>Gross pay is the weekly salary which was previously entered for the employee. </p> <p>Net pay is calculated as the gross pay minus the amount of tax. </p> <p>To calculate tax: Deduct $1 from the salary for each withholding exemption. This is the adjusted income. If the adjusted income is less than 0, then use 0 as the adjusted income. </p> <p>Multiply the adjusted income by the tax rate, which you should assume is a flat 25%. </p> <p>As an example, if Bob Cratchit has a weekly income of $15 and 7 dependents, then his adjusted income would be $8. His tax would be 25% of $8 which is $2, and therefore his net pay is $13.</p> <p>I have started trying to get this. I put it between the second loop and the last loop. Is this right?</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.
 

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