Computer Science Canada

Help??????????????????

Author:  NAS [ Tue Nov 12, 2002 4:25 pm ]
Post subject:  Help??????????????????

Help me please

Write a program to plot a horizontal line of minus signs in any row
Of the window that you specify.

Author:  FizixMan [ Tue Nov 12, 2002 6:25 pm ]
Post subject: 

I wrote the program, it's quite short actually, to post here for you. But that would defeat the purpose of you doing it and not really learning anything. I can suggest to you though how to go about tackling the problem (and if someone else wants to put up the source code, that's fine with me)

First off, we know we need user input for an integer. So that's easy enough with a 'get' statement. And then you'll need to use 'locate' to get the cursor to that row. So like locate (row,1), this will toss the cursor at the desired row and at the far left side.

Then you can use a for loop (from 1 to maxcol) to put in all the hyphons. Just remember to put the ".." at the end of the put statement so the program doesn't carriage return. BTW, "maxcol" is a constant that is put in the program automatically if you didn't know, it's the maximum column value, that way you won't go past the screen.

Hope this helps.

Author:  NAS [ Tue Nov 12, 2002 11:07 pm ]
Post subject:  yo bro

yo bro what is the code help me Shocked

Author:  Mike Pastah [ Wed Nov 13, 2002 1:38 am ]
Post subject: 

Fine, because I'm nice... but don't blame me if you get in trouble for using code you haven't learnt, and get blamed for cheating... Wink

code:

var a: int
put "Enter the row number " ..
get a
cls
locate (a, 1)
for i : 1 .. maxcol
    put "-" ..
end for


there... But you really should try to figure it out on your own...

Author:  KeNNy [ Wed Nov 20, 2002 6:10 pm ]
Post subject:  weeeeeeeeee

Go through what ^he^ said row by row, and try and understand how it works instead of copying and pasting. You won't have a chance to ask questions before a final exams because you won't know the questions.

Author:  Crimson_Hunter [ Fri Nov 22, 2002 6:44 pm ]
Post subject: 

btw if you CAN'T Understand this, it's just so very wrong. drop the class.
easier version

There are 25 rows, and 80 coloums

code:
var row : int %Declares the varable to store information
put "Enter the number of the row to output minus signs" %Tells the user %%what to do

get row %Enters an integer (any whole number) from the keyboard at  %%runtime %Assume the user enters the row 4

locate (row, 1) % brings the cursor to row 4, coloum 1.
put repeat ("-", 80) %it outputs - signs 80 times

%This would also work with a for statement, but peronally find this easier.

%for the "repeat ("-", 80)" it would also work with: put repeat ("--", 40)
%and it would work with: put repeat ("----", 20)
%The repeat function will take the first literal or variable and make it a
%string, and it will output it x times, where x is 20 in this case

%!-- End program


if you are one of those types that will acctually try to learn this stuff, as apposed to one of those people that won't even look at it, then good luck. But you are one of those: "HELP ME I'M FAILING TEACH ME GIVE ME PROGRAMS DO MY PROJECT FOR ME" people then you should drop the course.

the following is an explanation for stuff you should know already
if you read the rest of this you are person type A :D

experiment with these programs

code:

1)

for i : 1.. 20
put "-".. %.. makes the cursor stay at the end of the line
end for

2)
for i : 1 .. 20
put "-"
end for

3)
put repeat ("-", 20)

4)
put repeat ("-", maxcol + 1) %maxcol is the number of coloums (80) on    % the output screen


more examples


if you say:
put "Hello"
put "John"
the screen will look like this:
code:

Hello
John
|

where the | is the cursor
if you put:
put "Hello"..
put "John"
code:

HelloJohn
|

get it?
if you are reading this: good luck
[/code]

Author:  Crimson_Hunter [ Fri Nov 22, 2002 6:45 pm ]
Post subject: 

okay the code didn't turn out like i wanted it to:

var row : int
get row
locate (row, 1)
put repeat ("-", 80)

There.


: