•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 425,995 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,677 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser: Programming Forums
Views: 3817 | Replies: 1
![]() |
•
•
Join Date: May 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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)
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.
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
LOOPMy 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.
•
•
Join Date: Nov 2006
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
Im actually working on somthing similar to this and would like to know if anyone has an answer to this question.
Thnx.
CF.
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.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Legacy and Other Languages Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Making arrays from text files (VB.NET)
- Printing problem with Qbasic (Legacy and Other Languages)
- Help with Array (C++)
- NTVDM Input Parameters for running QBASIC (Visual Basic 4 / 5 / 6)
- need help with fstream input files (C++)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: Call Perl program from sed.
- Next Thread: Rational ClearCase


Linear Mode