It looks like you're new here. If you want to get involved, click one of these buttons!

tro44_1
Member Posts: **1,819**

Look at the following problems and identify

a) the output

b) the input

c) the procedure

3. Dew Drop Inn, has a different rate structure. Here a guest pays by the week (7 nights). The rate is reasonable - $350. per week. But the guest must always pay for an entire week even if he stays less than the full week. Thus, 4 nights would cost 350. as would 7. If a guest stays 8 nights then he must pay for 2 weeks….or 350 times 2. The tax is still 7.5% and the energy charge is 3.50 per night. . Write a program which will allow you to enter a guest's name and the number of nights he stayed at the Inn. Print an itemized bill which shows the cost for the room, the tax, the energy charge and the total tax.

Hint. Since you are entering the number of nights, you will have to convert that to weeks.

HINT: You might be considering "if" for this. (if nights>7 and nights<15, weeks = 2) DON'T DO THIS you would never be able to stop saying "if"….

Think about / which can be used to convert to weeks.

---------------------------------

This is the problem I have above.

The trouble iam having is, how do I use the Night--to--Week conversion to find weekly prices, without using (<|> if/Then) statements?

This is confusing me.

For example, if the person stayed in the hotel for 6 days, ---- That would be 6/7 in weeks,

but if I mutiple 6/7 *350, it wont give me the correct weekly price, since that would be less then 350$.

I dont know how to round up numbers using (+ - * / < >) operators.

## Comments

7,357Just a simple direction - try whatever language's Date() object.

3,561Use the modulo operator.

6 % 7 = x

11 % 7 = y

254 % 7 = z

70 % 7 = a

You'd get x = 6, y = 4, z = 2, a = 0 from the above. So modulo will always tell the number of days short of the last full week.

So if there was a function you made that accepted an integer and did the following, it'd always pass you the number of days right back presuming you're working with integer types (whole numbers that truncate and not round decimal places, i.e. 3 / 2 = 1 and not 1.5 rounded up to 2)

x = 6, y = 11, z = 254, a = 70

((x / 7) * 7) + (x % 7) = 6 days

((y / 7) * 7) + (y % 7) = 11 days

((z / 7) * 7) + (z % 7) = 254 days

((a / 7) * 7) + (a % 7) = 70 days

'course, dividing and then multiplying by 7 seems redundant there, but its not given the way integers work, i.e. with the 254 days example, 254 / 7 = 36, 36 x 7 = 252. The truncation of decimal places there works to your benefit in giving you the number of days in a full week, and the last modulo operation will give you the number of days in the remaining week.

That what you were looking for?

30I think you should try the module operator because it is the only manual way to build your program but it's difficult because when we use the tools it will easily generate a program and when we talk about the module then it takes more work as compare to tools. But should not worry now because there are thousands of tools have been introduced in the market which may help you to generate a program which you want. Even now we can easily use the best essay writing help for our projects and work because of thousands of online sites on the internet. These online sites not only help you to complete your work but also help you to get good marks in the exams as well. So, we should visit these sites to get help in our projects.

1