Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

program ? 3

Status
Not open for further replies.

advpay

Programmer
Mar 22, 2000
57
US
<br>The Twelve Days of Christmas:<br>Each year, a National Bank of publishes a Christmas price list. <br><br>(See table 6.11) Write a program that requests an integer from 1 to 12 and <br>then lists the gifts for that day along with that day's cost. On the nth day, <br>the n gifts are 1 partridge in a pear tree, 2 turtle doves,...n of the nth <br>item.<br><br>The program should also give the total cost of all twelve days. As example, Figure 6.26 shows the output in the picture box when the user enters <br><br>3. <br>6.11<br>ITEM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COST<br>partridge in a pear tree&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;27.50<br>turtle dove&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;25.00<br>French hen&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5.00<br>calling bird&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;95.75<br>drummer drumming&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;95.00<br><br>6.16<br><br>The gifts for day 3 are<br>1 partridge in a pear tree<br>2 turtle doves<br>3 French hens<br>Cost: $92.50<br><br>Total cost for the twelve days: $71,613.50<br><br>*I have to use a for loop*<br><br>Thanks for the help...Aaron
 
Put all of the items in a Combobox<br>Then put the costs in a array<br>So when you click the combo box it gets the day finds the cost in a the array and adds it up.<br>Cost = Cost + NewDayCost<br>When you pick a day store the Cost in a Public variable <br>Have a total box which has the &quot;Cost&quot; put in it.<br>So each time you click the Combobox and select an item it adds the cost of that item updating the total.<br><br>2 minute job.<br><br>
 
advpay -<br><br>Do like DougP says.<br><br>But, if I may say so, you really shouldn't be posting homework questions here.&nbsp;&nbsp;We're glad to help, but being a student is more than learning a language syntax -- it's learning how to break a problem down into manageble pieces.&nbsp;&nbsp;Once you've mastered that, language syntax is cookbook stuff (ie. dig out the manual, look it up).<br><br>I hope you haven't taken offense at my post (if you want to red-flag this reply, go ahead -- it'll be a new experience for me!), and I'd like to see you return to Tek-Tips.&nbsp;&nbsp;There's a lot more to being a programmer than what your professor is telling you, and I think you can pick up on some of it here.<br><br>Chip H.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top