It looks like you're new here. If you want to get involved, click one of these buttons!
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
Just a simple direction - try whatever language's Date() object.
Use 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?
I 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.
Wait while I call ATT and the Geek Squad to help me with this. Maybe I will get hypothesis help on this basic problem. Better yet, let me ask an English tutor they surely would know.
BTW modulo won't work in this case. What useful info will you get from a modulo when all you need to do is divide by seven and round up?
float unroundedWeeks = (days/7) + 0.5;
int weeks = unroundedWeeks;
With shader scripts, its best to avoid branching. So figuring out how to do something without using a Boolean operation is good practice.
Furthermore, taking an integer and adding 0.5, then casting the resulting float back to an integer, will likely only give you what you started with. A cast customarily truncates, not rounds. Some languages would want your cast to be more explicit than that when you go from a float to an int.
If the goal is to round up rather than down, then something like:
int weeks = (days + 6) / 7;
will do it. Alternatively, if you're willing to assume that the numbers aren't large enough for floating-point rounding issues to become a problem, you could get rid of the divide by saying:
int weeks = (int)fma(days, 0.142857f, 0.99f);
Making unnecessary assumptions like that might get you docked points in a class, though.
And yes, I realize that the original poster hasn't come here in so long that the forum isn't sure when he was last active.
This problem requires some logical thinking and mathematical operations to calculate the bill without using if-then statements. You can achieve this by using integer division and modulus operations to convert the number of nights to weeks and calculate the total cost accordingly. More information you can found with this