Advertisement
Guest User

Untitled

a guest
Dec 7th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 2.43 KB | None | 0 0
  1. '*************************************...
  2. '* THIS PROGRAM IS TO CALCULATE CAR RENTAL REVENUE GENERATED *
  3. '*************************************...
  4. 'VARIABLE USED:
  5. 'T1$, H1$, H2$, D1$ Customer Name
  6. 'NAM $ Employee Name
  7. 'VEHICALTYPE$ Vehicle Type
  8. 'MILAGE Miles Traveled
  9. 'RATE Vehicle Rate
  10. 'DAYS Days Held
  11. 'TOTAL Total Revenue Generated Per Account
  12.  
  13. '*************************************...
  14. '* PROGRAM MAINLINE *
  15. '*************************************...
  16. CLS
  17. GOSUB InitializeVariables
  18. GOSUB PrintHeadings
  19. GOSUB ProcessDetail
  20. GOSUB CalculateAnswer
  21. END
  22.  
  23. '*************************************...
  24. '* INITILIZE VARIABLES *
  25. '*************************************...
  26.  
  27. InitializeVariables:
  28. LET T1$ = " CAR RENTAL AUGUST 2011 "
  29. LET H1$ = " Customer Vehical Days Miles Total Cost"
  30. LET H2$ = " Name Type Held Traveled For Rental"
  31. LET D1$ = "/ / / / ## #### ######"
  32.  
  33. '*************************************...
  34. '* PRINT HEADINGS *
  35. '*************************************...
  36. PrintHeadings:
  37. PRINT
  38. PRINT T1$ 'Print Title Line
  39. PRINT
  40. PRINT H1$ 'Print Column Heading, Line 1
  41. PRINT H2$ 'Print Column Heading, Line 2
  42. PRINT
  43. RETURN
  44.  
  45. '*************************************...
  46. '* PROCESS DETAIL *
  47. '*************************************...
  48. ProcessDetail:
  49. GOSUB ReadData 'Prime the data read
  50. DO UNTIL UCASE$(NAM$) = "END"
  51. GOSUB CalculateVehicalCost
  52. GOSUB CalculateAnswer
  53. GOSUB ReadData
  54. LOOP
  55. RETURN
  56.  
  57. '*************************************...
  58. '* READ DATA *
  59. '*************************************...
  60.  
  61. ReadData:
  62. READ NAM$, VehicalType$, DaysHeld, MilesTraveled
  63. DATA "Jones","Large",6,500
  64. DATA "Smith","Compact",17,3000
  65. DATA "Baker","Intermediate",8,250
  66. DATA "Williams","Intermediate",4,1000
  67. DATA "Winston","Large",3,500
  68. DATA "END",0,0,0
  69. RETURN
  70.  
  71. '*************************************...
  72. '* CALCULATE VEHICAL COST *
  73. '*************************************...
  74. CalculateVehicalCost:
  75. LET Compact = (MilesTraveled * .15)
  76. LET Intermediate = (MilesTraveled * .18)
  77. LET Large = (MilesTraveled * .22)
  78.  
  79. '*************************************...
  80. '* CALCULATE ANSWER *
  81. '*************************************...
  82. CalculateAnswer:
  83. LET TotalCostForRental = (VehicalType * DaysHeld)
  84.  
  85. '*************************************...
  86. '* PRINT DETAIL *
  87. '*************************************...
  88. PrintDetail:
  89. PRINT USING D1$; NAM$, VehicalType, DaysHeld, MilesTraveled
  90. RETURN
  91. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement