Microwave Oven

Jeffrey Samuel

Greenhorn

Posts: 2

posted 7 years ago

Hi, I have a problem with this code. I'm not sure if this is right. The question is:

A microwave oven manufacturer recommends that when heating two items, add 50% to the heating time, and when heating three items double the heating time. Heating more than three items at once is not recommended.

Write a program that asks the user for the number of items and the single-item heating time. The program then writes out the recommended heating time.

1) it would greatly help others if you properly indented your code. it's VERY hard to read otherwise. if you want folks to help you, you should make it as easy as possible.

2) Generally, you'll get the best/most help if you ask a SPECIFIC question. For example..."How would I format the output to look like blah blah blah". What you have posted is your homework assignment, some partial code...and nothing else. Nobody knows WHERE you are stuck, what you are trying to do, etc. It look like you are hoping someone will just do this for you - and we don't do that here.

3) i'm guessing you need help with what goes in your "else if (numItems == 2)" block? if so, think about what the requirements say you should do for two items. if someone enters "30" (assuming seconds), how long should 2 items ACTUALLY cook for? what if they enter 10 seconds? after you figure that out, ask yourself HOW EXACTLY you calculated your answer. Did you add something? divide? take the sine of an angle? you probably did some kind of math. If you get a specific answer (like "i took 10 and raised it to the 3rd power, and I took 30 seconds and raised it to the third power"), see if you can generalize it into an equation, like "I took the input and raised it to the third power".

Once you figure out how to do this in ENGLISH (or whatever your native language is), see if you can translate it into code, a little at a time.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors