Added star-shapes exercise

This commit is contained in:
raul 2024-01-19 08:03:40 +00:00
parent 8cd5dfcdc5
commit d9f17e78a3
1 changed files with 58 additions and 0 deletions

58
star-shapes/main.go Normal file
View File

@ -0,0 +1,58 @@
package main
import "fmt"
func main() {
var numStar int
var numShape int
fmt.Println("How many stars do you want?")
fmt.Printf(" Stars: ")
fmt.Scan(&numStar)
fmt.Printf("\n")
fmt.Println("Which shape would you like?\n Line [1]\n Square [2]\n Flag [3]")
fmt.Printf("Shape: ")
fmt.Scan(&numShape)
switch numShape {
case 1:
println("Line")
case 2:
fmt.Println("Square")
case 3:
fmt.Println("Flag")
default:
fmt.Println("Invalid input, please use either 1, 2 or 3.")
}
//flag(numStar)
}
func line(num int) {
for i := 0; i < num; i++ {
fmt.Printf("* ")
}
fmt.Printf("\n")
}
func square(num int) {
for i := 0; i < num; i++ {
for i := 0; i < num; i++ {
fmt.Printf("* ")
}
fmt.Printf("\n")
}
}
func flag(num int) {
for a := 0; a < num; a++ {
for i := -1; i < a; i++ {
fmt.Printf("* ")
}
fmt.Printf("\n")
}
for i := 0; i < num/2; i++ {
println("*")
}
}