User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: May 2006
Posts: 1
Reputation: sajo69 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sajo69 sajo69 is offline Offline
Newbie Poster

Help HELP with 2D Arrays Input Files-CrimsonEd/QBasic

  #1  
May 7th, 2006
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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2006
Posts: 1
Reputation: Codeflunky is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Codeflunky Codeflunky is offline Offline
Newbie Poster

Re: HELP with 2D Arrays Input Files-CrimsonEd/QBasic

  #2  
Nov 2nd, 2006
Im actually working on somthing similar to this and would like to know if anyone has an answer to this question.

Thnx.

CF.

Originally Posted by sajo69 View Post
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Legacy and Other Languages Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Legacy and Other Languages Forum

All times are GMT -4. The time now is 12:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC