Week 9: Easy
Write a Text Window program that asks the user for a width and height.
The program will then draw a rectangle with these dimensions using asterisks (*)Example:
What is the width? 10
What is the height? 5
Here is your rectangle:
**********
**********
**********
**********
**********
Scrivi un programma per la finestra di testo che chiede all’utente una larghezza e un’altezza e dopo disegna un rettangolo con queste dimensioni utilizzando asterischi.
Soluzione
Il codice seguente visualizza una riga di asterischi
- visualizza più volte (larghezza) un asterisco
- va a capo
For colonna=1 To larghezza
TextWindow.Write("*")
EndFor
TextWindow.WriteLine("")
Ripetendo più volte (altezza) l’esecuzione del codice precedente si ottiene il rettangolo di asterischi
'------------------------------------ INPUT
TextWindow.Write("Larghezza: ")
larghezza=TextWindow.ReadNumber()
TextWindow.Write("Altezza: ")
altezza=TextWindow.ReadNumber()
TextWindow.WriteLine("")
'------------------------------------ ELABORAZIONE E OUTPUT
For riga=1 To altezza
For colonna=1 To larghezza
TextWindow.Write("*")
EndFor
TextWindow.WriteLine("")
EndFor