Thread: Help with code please
-
November 9th, 2009, 04:28 AM #1Junior Member
- Join Date
- Nov 2009
- Posts
- 1
Help with code please
I have to write a program based on the 12 days of x-mas that requests an integer from 1 -12 and then lists the gifts for that day along with that day's cost. (Each item has a price which is listed in a text file) It also has to show the total cost for all 12 days. Here is a sample output if user inputs day 3.
The gifts for day 3 are
1 partridge in a pear tree ($164.99)
2 turtle doves ($20 each)
3 french hens ($15 each)
cost: $249.99
Total cost for the twelve days: $78,100.30
Here is my code that I have written but it is not working. It is in VB 2008
Thanks
Public Class frmChristmas
Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
Dim name As String
Dim count As Integer
Dim price, cost, totalCost As Double
Dim sr As IO.StreamReader = IO.File.OpenText("Christmas.txt")
count = CInt(sr.ReadLine)
count += 1
cost = price * count
For i As Integer = 1 To count
name = sr.ReadLine
Next
sr.Close()
For i As Integer = 1 To 12
IO.File.OpenText("Christmas.txt")
count = CInt(sr.ReadLine)
name = sr.ReadLine
count += 1
cost = price * count
totalCost += cost
lstOutput.Items.Add("The gifts for day" & count & "are")
Next
sr.Close()
End Sub
End Class
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
IS CODE PURPLE LIKE CODE RED TO PEOPLE
By EMILIE in forum Technical SupportReplies: 1Last Post: September 24th, 2009, 09:12 PM -
Code 29
By kevin892 in forum Applications and Operating SystemsReplies: 0Last Post: March 27th, 2007, 01:11 PM -
What is the Code for..?
By Gyurza in forum General Tech DiscussionReplies: 6Last Post: January 20th, 2006, 05:23 AM -
HELP !!!!!! - Code 12
By pluke100 in forum Technical SupportReplies: 8Last Post: August 23rd, 2005, 09:49 PM -
Could someone help me with this code?
By Ritalin Kid in forum Webmastering and ProgrammingReplies: 7Last Post: February 20th, 2002, 08:13 PM



LinkBack URL
About LinkBacks



Reply With Quote

Won a cheap audio compressor on eBay, and received a digital room relay. :confused: :heh: Seller had the room delay for auction as well, so I suspect its winner received my compressor. ;) Now...
Is It Just Me? v233893843