my program
package main
import (
"fmt"
)
const max = 10
func main() {
var plat, dan, zdanenie float64
var n int
var polecisla [max]int
pokus := 1
sanca := 4
a := 0
sumacisla := 0
fmt.Printf("Zadajte pocet platov,ktore chcete vlozit.\n (min.1 a max.%d)\nPotom postupne zadavajte platy.\nJednotlive platy potvrzujte enterom.\n!!! Mozu byt aj desatine cisla !!!\t\t", max)
fmt.Scanf("%d", &n)
for (n <= 0) || (n > max) {
if n <= 0 {
fmt.Printf("\nMin.pocet platov je 1!!\n\nZadajte pocet platov ktore chcete vlozit.\n")
}
if n > max {
fmt.Printf("\nMax.pocet platov je %d !!\n\nZadajte pocet platov ktore chcete vlozit.\n", max)
}
fmt.Printf("(Toto bol %d.pokus,zostavaju %d)\t", pokus, sanca)
fmt.Scanf("%d", &n)
pokus++
sanca--
if sanca == 0 {
break
}
}
if (n > 0) && (n <= max) {
fmt.Printf("\n")
}
for a < n {
fmt.Scanf("%d", &polecisla[a])
sumacisla += polecisla[a]
a++
fmt.Scanf("%f", &plat)
if plat > 2400 {
dan = 0.22 * plat
zdanenie = plat - dan
}
if plat <= 2400 {
dan = 0.19 * plat
zdanenie = plat - dan
}
fmt.Printf("plat %.2f \t\n", plat)
plat++
fmt.Printf("plat po zdaneni je:%.2f", zdanenie)
fmt.Printf("\n")
}
}
why does my program do that if I enter the wrong input, it throws me into the console 2 times in a row? when will it fire me only once?
increase it by only one and not two
thank you for help