# we have corn!!

This is a discussion on we have corn!! within the C Programming forums, part of the General Programming Boards category; lol i just need some help with this problem. my question is, which statements to consider. Im assuming the "if" ...

1. ## we have corn!!

lol i just need some help with this problem. my question is, which statements to consider. Im assuming the "if" statement to start. Remember I'm a complete noob to this and any tips would be greatly appreciated!

here it is:

1. Hey, this is Vermont -- we've got corn!

Write a program that accepts the number of ears of corn the customer is purchasing and outputs the total price. The corn is priced according to the following four statements:

If the customer is purchasing less than a dozen ears, the price per ear is \$0.50.
If the customer is purchasing 12 to 23 ears, the price per ear is \$0.45.
If the customer is purchasing 24 to 35 ears, the price per ear is \$0.40.
If the customer is purchasing more than 35 ears, the price per ear is \$0.35.

You will need to use scanf to ask the user for the number of ears of corn being purchased, and then figure out the correct price to display. Ideally, you should only use 2 printfs, one to ask for the number of ears, and one which displays the total price

2. I don't think "which statements to consider" is an approach that has ever really worked in programming. Figure out what you want to do. Once you know what you want to do, that will tell you what statements to use to make it happen.

First step, then, is: write out, in English, the steps the program should take.

3. tab,

you have brought a very important point. Thank you

4. Originally Posted by theor23
lol i just need some help with this problem. my question is, which statements to consider. Im assuming the "if" statement to start. Remember I'm a complete noob to this and any tips would be greatly appreciated!
Writing code is the *last* step in programming... The first step is understanding the problem that is to be solved... Then comes defining a solution... then you need to write code. Believe me, if you don't understand how to solve the problem, you will never write the software...

5. 'if' statements seem reasonable. Mimic the same as the English description...
Something like...
Code:
```if (ears < 12)
cost = 0.5;
else if (ears < 24)
cost = 0.45;
else if (ears < 36)
cost = 0.4;
else cost = 0.35;```

6. Originally Posted by CommonTater
Writing code is the *last* step in programming... The first step is understanding the problem that is to be solved... Then comes defining a solution... then you need to write code. Believe me, if you don't understand how to solve the problem, you will never write the software...
I'm really glad you brought this point up. I will follow this rule of thumb always, thanks again

7. thank you nonoob