Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Program with loops

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
I need help with this program.

This program prints a graph of children's ages.
Use the following data:
DATA "Jim", "Jones", 18, "Nancy", "Smith", 12, "Terry", "Bowden", 9, "Michael", Hayes, 19
DATA "Jane", "Doe", 14, "Paula", "Jones", 8, "Richard", "Chamberlin", 13, "Christine", "Pratt", 18
DATA "Glen", "Taylor", 12, "Adam", "Schott", 15

Your output should look like this:


NAME AGE
J. Jones ******************
N. Smith ************
.
.

Please help me!!
 
Post what you have and somebody will probably look at it and give suggestions.
This is a precaution to avoid doing homework assignments. Ed Fair
efair@atlnet.com

Any advice I give is my best judgement based on my interpretation of the facts you supply.

Help increase my knowledge by providing some feedback, good or bad, on any advice I have given.

 
try this easy way:

CLS
? "NAMES", ; , "AGE": ?
ON ERROR GOTO endp : rem exit the loop
DO
READ firstname$, lastname$, age$
? firstname$; " "; lastname$, ; , age$
LOOP
endp:
DATA "Jim", "Jones", "18", "Nancy", "Smith", "12", "Terry", "Bowden", "9", "Michael", Hayes, "19"
DATA "Jane", "Doe", "14", "Paula", "Jones", "8", "Richard", "Chamberlin", "13", "Christine", "Pratt", "18"
DATA "Glen", "Taylor", "12", "Adam", "Schott", "15", "end"
END

miguel
migoul@hotmail.com
 
this creates the right output:


ON ERROR GOTO endp
CLS
PRINT "NAME", "AGE"
DO
READ firstname$, lastname$, age
PRINT LEFT$(firstname$, 1); ". "; lastname$,
PRINT STRING$(age, ASC("*"))
LOOP
endp:
END

DATA "Jim", "Jones", 18, "Nancy", "Smith", 12,
DATA "Terry", "Bowden", 9, "Michael", Hayes, 19
DATA "Jane", "Doe", 14, "Paula", "Jones", 8,
DATA "Richard", "Chamberlin", 13, "Christine", "Pratt", 18
DATA "Glen", "Taylor", 12, "Adam", "Schott", 15
 
I would only recommend using the TAB() function to set a literal point to start. The comma being used will set the starting point of the next print command to the next print region, and if the NAME is shorter or longer than the last one the next print region may vary.

--MiggyD "The world shrinks more and more with every new user online."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top