HI, I am a new person to the forum and also a pretty new person to coding. I am having difficulty with an assignment and need some direction.
Here's the problem: I'm a car sales person who is giving discounts on certain styles and years of cars. In my 2D array table input file, rows represent the year of the car (1-2003, 2=2002, 3=2001, 4=2000, 5=1999, 6=1998) and columns represent style of car as a code number (1= mini, 2=small, 3=medium, 4=full-size,5=luxury). The discount percentage table I have on file reads like this:

0.050, 0.055, 0.060, 0.065, 0.070
0.040, 0.045, 0.050, 0.055, 0.060
0.030, 0.035. 0.040, 0.045, 0.050
0.020, 0.025, 0.030, 0.035, 0.040
0.010, 0.015, 0.020, 0.025, 0.030
0.005, 0.010, 0.015, 0.020, 0.025

The code I have written so far is as follows: (it is not completely worked out yet, so please don't laugh...too much)

``````DIM disc (6,5) AS String
DIM price AS Double
DIM row AS String
DIM column AS String
DIM discountPercent AS String
DIM discountAmount AS Double
DIM finalPrice AS Double
DIM totalCars AS Integer
DIM endOfDay As Integer
DIM i AS Integer

i = 0
totalCars = 0
endOfDay = 0

OPEN "DiscCars.txt" for INPUT AS #1

DO WHILE i < 6
INPUT #1, disc(i,0), disc(i,1), disc(i,2), disc(i,3), disc(i,4)

i = i + 1
PRINT "Enter Suggested Price of Car (or 0 to exit): \$", price

close #1
LOOP

DO WHILE price <> endOfDay

PRINT "Enter year of vehicle: " row
PRINT "Enter Style code: " column

discountPercent = (row)(column)
PRINT "Discount Percentage is %", discountPercent

discountAmount = price * discountPercent
PRINT "Discount Amount is: \$ ", discountAmount

finalPrice = price - discountAmount
PRINT "Your Final Sales Total is: \$ ;, finalPrice

totalCars = totalCars + 1
PRINT "Today, you sold", totalCars, "cars!"
IF totatCars > 5 THEN
PRINT "Well Done!!"
ELSE
PRINT "You need to work harder!"
ENDIF

PRINT "Enter Suggested Price of Car (or 0 to exit): \$", price
LOOP``````

My major problem is I cannot figure out how to get the DiscCars.txt file figures to read into my code so I can calculate row and column to get discount percent (output to screen). How do I code the row and column calculations?
Any takers?

Thanks,
Sandy
Let me know if you need further info.

Im actually working on somthing similar to this and would like to know if anyone has an answer to this question.

Thnx.

CF.

HI, I am a new person to the forum and also a pretty new person to coding. I am having difficulty with an assignment and need some direction.
Here's the problem: I'm a car sales person who is giving discounts on certain styles and years of cars. In my 2D array table input file, rows represent the year of the car (1-2003, 2=2002, 3=2001, 4=2000, 5=1999, 6=1998) and columns represent style of car as a code number (1= mini, 2=small, 3=medium, 4=full-size,5=luxury). The discount percentage table I have on file reads like this:

0.050, 0.055, 0.060, 0.065, 0.070
0.040, 0.045, 0.050, 0.055, 0.060
0.030, 0.035. 0.040, 0.045, 0.050
0.020, 0.025, 0.030, 0.035, 0.040
0.010, 0.015, 0.020, 0.025, 0.030
0.005, 0.010, 0.015, 0.020, 0.025

The code I have written so far is as follows: (it is not completely worked out yet, so please don't laugh...too much)

``````DIM disc (6,5) AS String
DIM price AS Double
DIM row AS String
DIM column AS String
DIM discountPercent AS String
DIM discountAmount AS Double
DIM finalPrice AS Double
DIM totalCars AS Integer
DIM endOfDay As Integer
DIM i AS Integer

i = 0
totalCars = 0
endOfDay = 0

OPEN "DiscCars.txt" for INPUT AS #1

DO WHILE i < 6
INPUT #1, disc(i,0), disc(i,1), disc(i,2), disc(i,3), disc(i,4)

i = i + 1
PRINT "Enter Suggested Price of Car (or 0 to exit): \$", price

close #1
LOOP

DO WHILE price <> endOfDay

PRINT "Enter year of vehicle: " row
PRINT "Enter Style code: " column

discountPercent = (row)(column)
PRINT "Discount Percentage is %", discountPercent

discountAmount = price * discountPercent
PRINT "Discount Amount is: \$ ", discountAmount

finalPrice = price - discountAmount
PRINT "Your Final Sales Total is: \$ ;, finalPrice

totalCars = totalCars + 1
PRINT "Today, you sold", totalCars, "cars!"
IF totatCars > 5 THEN
PRINT "Well Done!!"
ELSE
PRINT "You need to work harder!"
ENDIF

PRINT "Enter Suggested Price of Car (or 0 to exit): \$", price
LOOP``````

My major problem is I cannot figure out how to get the DiscCars.txt file figures to read into my code so I can calculate row and column to get discount percent (output to screen). How do I code the row and column calculations?
Any takers?

Thanks,
Sandy
Let me know if you need further info.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.