Hey everyone, I'm new to this site. one of my classmates told me about it so I'm giving it a try. anyway, for my class I need to write a code for a payroll program.

so far, this is what I've written...

``````//Assignment 4
//Page 218
//Question 7

#include <iostream>
#include <string>

using std::cout;
using std::cin;
using std::endl;
using std::string;

int main()
{
//Variables
int hoursworked = 0;
int weeksworked = 0;
int daysworked = 0;
int hoursleft = 0;
string name = "";

//Input
cout << "Enter the name of the worker please: ";
getline(cin, name);
cout << "Enter the total hours worked please: ";
cin >> hoursworked;

//Calculate

.
.
.
.
.``````

so basically I'm confused on what I'm calculating. reason being is because I need the output to display hours worked in a this format... hours worked is 70, so the output should read 1 week, 3 days, 6 hours. this is assuming the work week is 40 hours with 8 hour days.

## All 3 Replies

> hours worked is 70, so the output should read 1 week, 3 days, 6 hours.
> this is assuming the work week is 40 hours with 8 hour days.

70 / 40 == 1 (integer division)
70 % 40 == 30 (modulus) http://www.vias.org/cppcourse/chap04_01.html
30 / 8 == 3
30 %8 == 6

right, I remember doing stuff like that in class with the remainder. but I can't really remember how to code that in terms of
weeksworked = hoursworked / 40;

right, I remember doing stuff like that in class with the remainder. but I can't really remember how to code that in terms of
weeksworked = hoursworked / 40;

Then you'd better start reading your book and asking questions in class. We are not a tutorial forum. Nor are we a homework service forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.