Compare commits

...

2 Commits

Author SHA1 Message Date
raul 24f0adac09 Cleanup 2024-01-29 17:43:28 +01:00
raul ce1106d3b3 Finished arrays exercise
I'm done with this exercise, it has become so convoluted that I can't
comprehend the codebase anymore, here be dragons
2024-01-29 17:40:49 +01:00
3 changed files with 34 additions and 31 deletions

View File

View File

@ -2,9 +2,9 @@ package main
import (
"fmt"
"log"
"os"
"time"
//"log"
//"time"
)
var notas []float64
@ -13,7 +13,6 @@ var choice int
func main() {
fmt.Print("\033[H\033[2J")
fmt.Printf("Welcome to the vector playground\n\n")
msg()
options()
@ -21,7 +20,14 @@ func main() {
func options() {
for {
fmt.Scanln(&choice)
if _, err := fmt.Scanln(&choice); err != nil {
log.Print("Something failed")
}
if choice == 0 {
return
}
switch choice {
case 1:
@ -43,6 +49,8 @@ func options() {
}
// There is no saving this codebase, it has become so convoluted I can barely comprehend anything anymore
func msg() {
fmt.Print("\033[H\033[2J")
fmt.Printf("[1] Add to vector\n")
@ -61,19 +69,35 @@ func addVec() {
} else {
msg()
fmt.Println("\nERROR: Invalid number")
fmt.Printf("\nERROR: Invalid number\nChoice: ")
return
}
notas = append(notas, num)
//time.Sleep(2 * time.Second)
fmt.Printf("You have added the number %v!", num)
time.Sleep(2 * time.Second)
//time.Sleep(2 * time.Second)
msg()
fmt.Printf("\nYou have added the number %v!\nChoice: ", num)
num = 0
}
func showResults() {
fmt.Printf("These are your current grades: \n")
fmt.Print(notas)
time.Sleep(2 * time.Second)
//time.Sleep(2 * time.Second)
msg()
min := notas[0]
max := notas[0]
for _, v := range notas {
if v < min {
min = v
}
}
for _, v := range notas {
if v > max {
max = v
}
}
fmt.Printf("\nThese are your current grades: \n")
fmt.Printf("%.2f\n", notas)
fmt.Printf("Lowest grade: %v\n", min)
fmt.Printf("Highest grade: %v\n", max)
fmt.Printf("Choice: ")
}

View File

@ -4,16 +4,8 @@ package main
import (
"fmt"
//"math")
)
// This is dumb
// func roundFloat(numero float64, precision uint) float64 {
// var radio = math.Pow(10, float64(precision))
// var resultado = math.Round(numero*radio) / radio
// return resultado
// }
const IVA float64 = 1.1
const costeFijo float64 = 15.0
@ -25,14 +17,6 @@ var numeroPartidos int32
var numeroApuestas int32
func main() {
// var IVA float64 = 1.21
//
// var costeFijo float64 = 15.0
//
// var partidoExtra float64 = 6.0
//
// var numeroPartidos int32
// var numeroApuestas int32
fmt.Printf("Cuantos partidos has visto?\nNúmero: ")
fmt.Scan(&numeroPartidos)
@ -56,12 +40,7 @@ func main() {
}
var precioFinal float64 = costeFijo + impuestoPartidos + impuestoApuestas
// var precioFinalMasIVA float64 = roundFloat(precioFinal*IVA, 2)
var precioFinalMasIVA float64 = precioFinal * IVA
fmt.Printf("\nLa factura del mes costará %.2f€!\n", precioFinal)
fmt.Printf("La factura del mes incluyendo IVA costará %.2f€!\n", precioFinalMasIVA)
// OH MY LORD, I DON'T NEED A DAMN FUNCTION JUST TO ROUND NUMBERS DOWN, I CAN
// LITERALLY JUST FORMAT TO FLOAT AND WRITE .$num BETWEEN % AND f
// I am the world's biggest dumbass
}