vb.net - Have to make a program that makes a pyramid -
i have gotten basics how input number of spaces in each row?
this ive done far:
sub main() dim var char dim numberofsymbols integer console.writeline("what variable want use form pyramid?") var = console.readline console.writeline("what number of symbols want start with? (odd number)") numberofsymbols = console.readline() 'taking numberofsymbols 5 console.write(" ") console.write(var) console.writeline() console.write(" ") x = 1 numberofsymbols - 2 console.write(var) next console.writeline() console.write(" ") x = 1 numberofsymbols console.write(var) next console.readkey() end sub
the output im getting
aaa aaaaa
im not checking in program see if odd number/one character , how should go making program if user chooses random odd number?
i know ill have use repeat until loop how input number of spaces in loop that?
here:
sub main() dim var char dim numberofsymbols integer console.writeline("what variable want use form pyramid?") var = console.readline console.writeline("what number of symbols want start with? (odd number)") numberofsymbols = console.readline() if numberofsymbols mod 2 = 0 numberofsymbols += 1 'to check if number , add '1' make odd, can use 'numberofsymbols -=1' subtract insead of adding dim spaces string dim vars string = 1 numberofsymbols step 2 spaces = new string(" ", (numberofsymbols - i) / 2) vars = new string(var, i) console.writeline(spaces + vars) next console.readkey() end sub
and if want add empty line after each row, can add following line:
' ' console.writeline() next
hope helps :)
Comments
Post a Comment