So far one part of my program seems to be working. But the other part is what I am confused about. Can someone please help me out here. Like at least guide me. I am not looking for an direct answer although it would help.
My task was: Your program should read in the information for an employee, calculate the vacation time and bonus amount for the employee, and display the employee's name, number of years worked, number of weeks of vacation and amount of bonus (on a single line). Please note that you are to print the actual amount of the bonus (calculated as 5% of the annual salary), and not simply the words 5% of salary".
This is what I have come up with:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string last_name, first_name;
int years_worked;
int salary, bonus;
int annual_salary;
for (int i=1; i<=8; i=i+1){
cout << "Enter last name: ";
cin >> last_name;
cout << "Enter first name: ";
cin >> first_name;
cout << "Enter years worked: ";
cin >> years_worked;
cout << "Enter salary: ";
cin >> salary;
I see that you do actually calculate a bonus value, but then you don't output it on the following two lines. Why not replaces "a bonus of $0 "; and " a bonus of $200 "; with the value of bonus you calculated on the line before?
matsom wrote:
these two lines are not specified in your assignment question, stick to the task
Maybe we're interpreting it differently, but to me it looks like that is required
...you are to print the actual amount of the bonus...
I don't know whether you need complex or simple program. If you need complex program, that is doing everything good. First you need to design your program, like emp_details, salary_details, and emp_calender structures. Get most of data from user except which you can calculate. Process data and display.
Sorry for not specifying whether it is a complex program. It is a simple program for an intro class. Also I was provided with two tables.
An employee's vacation time is based upon the following table:
Years worked Weeks of vacation
0-3 1
4-6 2
7 or more 3
Bonuses are determined by the following table:
Years worked Bonus
0-4 None
5-9 $200
10 or more 5% of annual salary
I am not sure where to go from here. Should I calculate the yearly salary by doing salary*12 and then calculating the annual salary by doing yearly salary*.05? The program compiles but it's just not in the right direction i guess. Any help is appreciated.
if (years_worked <= 4) cout << "a bonus of $0 ";
else if (years_worked >= 10) cout << " a bonus of " << annual_salary;
else cout << " a bonus of $200 ";