Qbasicnews.com
February 23, 2020, 08:35:16 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: I need some help in this since im new  (Read 9242 times)
yusef
New Member

Posts: 1


« on: March 14, 2006, 07:42:00 PM »

CLS
TYPE CAR
CarName AS STRING * 16
price AS INTEGER
END TYPE
DIM I(2) AS CAR

TYPE customer
custname AS STRING * 4
bill AS INTEGER
Vericode AS INTEGER
END TYPE

DIM P(1) AS customer

I(0).CarName = "Mazda Special ZX"
I(0).price = 455
I(1).CarName = "Kingston Coupe +"
I(1).price = 755
I(2).CarName = "Classic Dragster"
I(2).price = 382

P(0).custname = "Kevin"
P(0).bill = 4500
P(0).Vericode = 3456

P(1).custname = "Eljah"
P(1).bill = 100
P(1).Vericode = 4748


DO
PRINT "Rent Cars Plus"
PRINT " 1 - Pay Bill"
PRINT " 2 - Rent Car"
PRINT " 3 - Purchase Insurance"
PRINT " 999 - Exit"



DO
INPUT "Choice: ", choice
IF choice = 999 THEN END



IF choice <> 999 AND choice <> 1 AND choice <> 2 AND choice <> 3 THEN
PRINT "Error Please Enter Correct Choice!"
END IF
LOOP UNTIL choice = 999 OR choice = 1 OR choice = 2 OR choice = 3



PRINT "Car No:"; x; I(x).CarName; " Price:"; I(x).price






FOR x = 0 TO 1
PRINT "Customer No:"; custname; " Name: "; P(x).custname
NEXT
IF choice = 1 THEN
INPUT "customer number: ", custname
INPUT "Payment Amount: ", payamount
INPUT "Vericode", Vericode
P(q).bill = P(q).bill - payamount
PRINT "Balance: "; P(q).bill

ELSE
FOR x = 0 TO 2
PRINT "Car No:"; x; I(x).CarName; " Price:"; I(x).price
NEXT x
INPUT " Renter Number: ", Rentnumber
INPUT " Vericode: ", Vericode
INPUT "Car Number to Rent: ", carnumber
INPUT " Number of Days to rent: ", days
I(q).price = days * I(q).price
P(W).bill = P(W).bill + I(q).price
PRINT "Balance: "; P(W).bill




END IF
LOOP

this is what i got so far
i sweared i tried for about 2 weeks non-stop cuz i got it due end of the month and i just took up this class

for my choice= 3 where someone purchases insurance i cant get at all
i know im asking alot of u but i waz hopin someone can finish this program for me

i would really love if u do
if u can also add a few lines of code that include such as that if someone doesnt enter the correct number of the car or any invalid number the user must enter till he or she can gets it correct or must exit

The database i will add more later
thanx in advance

im tryin my best in qbasic but between work n rest of skool work i cant keep up much hours on da program
Logged
thegrogen
Ancient QBer
****
Posts: 444



« Reply #1 on: March 14, 2006, 07:53:04 PM »

Sorry, but we can't really help you. Here's why:

1) It's a homework question, and AFAIK homework questions are not allowed here. Homework is just that, homework, and you shouldn't be asking people to do it for you. You don't learn anything that way.

2) We don't really know what you're asking us to code. We don't know what the program is supposed to do, so how can we finish it?

3) The insurance thing is something you should know from another class (probably math). If you don't know how to do insurance in the first place, I suggest telling your teacher this and work from there. If you do know how to do insurance on PAPER, then you should be able to work it out on your own.

Not that I'm flaming you, but that's just what I noticed. Also, I suggest improving your grammar, as people are less likely to listen to you and will consider you juvenile if you don't use proper grammar in your posts. Just a suggestion.  Tongue
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #2 on: March 14, 2006, 09:47:02 PM »

Rule #1

Never use TYPEs unless you really have to ... in this case I don't think you do... makes it easier to conceptualize with smaller programs.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
thegrogen
Ancient QBer
****
Posts: 444



« Reply #3 on: March 14, 2006, 10:56:04 PM »

Quote from: "Agamemnus"
Rule #1

Never use TYPEs unless you really have to ... in this case I don't think you do... makes it easier to conceptualize with smaller programs.


No, this is one instance where a TYPE would be useful. His professor might want him to expand the program so that more cars/customers can be used. It's generally a good idea to design for that, with a few exceptions (of which this isn't one).

Plus, he probably has to use TYPEs as part of the assignment.
Logged

.14159265358979323846264338327950288419716939937510582709445
Glarplesnarkleflibbertygibbertygarbethparkentalelelangathaffendoinkadonkeydingdonkaspamahedron.
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #4 on: March 15, 2006, 02:40:13 AM »

Don't see it.. there are only a few entries...... besides, TYPE should really only be used when you have a lot of different structures. If you have a lot of entries that doesn't sway it one way or the other.... assuming you started right to begin with..

Trust me, I am Yoda.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Anonymous
Guest
« Reply #5 on: March 15, 2006, 05:01:44 AM »

use types and pass them to functions that operate on them. :p
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #6 on: March 15, 2006, 05:41:45 AM »

Quote from: "Agamemnus"
Rule #1

Never use TYPEs unless you really have to ... in this case I don't think you do... makes it easier to conceptualize with smaller programs.


Rule #0: Never pay attention to Agamemnus rules.

Type structures are there for a reason and they are incredibly useful, specially in the mentioned case.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Radical Raccoon
I hold this place together
*****
Posts: 914



WWW
« Reply #7 on: March 15, 2006, 06:56:36 AM »

TYPEs rock! They're like classes, but not really.  :-?
Logged

RyanKelly
Forum Regular
**
Posts: 109



WWW
« Reply #8 on: March 16, 2006, 01:40:35 AM »

If you look at the method his program was tending toward, a user defined type made perfect sense.  He was trying to proccess a collection of related data of different types within a loop via an index.  Other than using an array of user define data types, the only useful method I can think of would be to declare seperate arrays for each piece of data.
Logged
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #9 on: March 16, 2006, 01:46:43 AM »

I should create a list of fundamental Agamemnus rules and get it over with..
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Moneo
Na_th_an
*****
Posts: 1971


« Reply #10 on: March 16, 2006, 05:14:05 PM »

Do it, Aga, and post the list. It would be interesting, and certainly generate discussion.
*****
Logged
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #11 on: March 17, 2006, 08:04:42 AM »

"101 rules to code in the 60's style by Agamemnus"?

Programming techniques have evolved since then - and for the better. Dismissing modern and better techniques "just because" is not necessarily bad, anybody is free to code the way he or she likes most. But teaching bad techniques in a forum where many people come to learn how to code is bad practice.

Type structures are one of the best inventions since structured programming. They let you semantically group related data and isolate it from the rest, for example. It's all about code structuration, robustness, scalability, stability and reusage,  which are vital concepts in programming.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Agamemnus
x/ \z
*****
Posts: 3491



« Reply #12 on: March 17, 2006, 12:04:02 PM »

Fine fine na_th_an... you win... It's not that bad to use a TYPE with a 50 line program, and I guess it helps to know about it.
Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Zack
*/-\*
*****
Posts: 3974



WWW
« Reply #13 on: March 17, 2006, 12:57:41 PM »

Rule #-1: Never listen to Nathan's rules about Aga.
Logged

f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Ralph
Ancient Guru
****
Posts: 544


« Reply #14 on: March 17, 2006, 01:38:31 PM »

Yusef:

Seems to me that your first problem exists here:
Code:

DO
INPUT "Choice: ", choice
IF choice = 999 THEN END



IF choice <> 999 AND choice <> 1 AND choice <> 2 AND choice <> 3 THEN
PRINT "Error Please Enter Correct Choice!"
END IF
LOOP UNTIL choice = 999 OR choice = 1 OR choice = 2 OR choice = 3



PRINT "Car No:"; x; I(x).CarName; " Price:"; I(x).price

Where do you difine x?  Think about it!
Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!