I got this homework today. A worker works for an amount of days (inputted by the user). 5% of the days he gets a bonus money (the amount is also inputted by the user). The length of workday is measured in hours. The number of workhours must be different and random for every day.For example day1 the workhours are 8 day2-4 day3-12 etc.
All the user input things are done, but when it comes to the calculations part I've made this loop.
for (int i=0;i<= totalDays;i++)
{
daysWithBonus=totalDays*(5/100)
bonusIncome=daysWithBonus*Bonus
moneyForTimeWorked=timeWorked*paymentForHour
totalIncome=bonusIncome+moneyForTimeWorked
}
Now my problem is that I can not get the timeWorked variable to be random and different for every day.I found this in the web:
int timeWorked = rand() % 9 + 3;
but it does not seem to work. Every time I run the program I get 8 for the value of the variable for each day. Can someone help me figure this out?