51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"bufio"
|
|
"fmt"
|
|
"os"
|
|
"strconv"
|
|
)
|
|
|
|
func main() {
|
|
|
|
wage, _ := input("Enter an hourly wage? ")
|
|
hours, _ := input("Enter total weekly hours: ")
|
|
|
|
wage_int, err := strconv.ParseFloat(wage, 10)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
hours_int, err := strconv.ParseFloat(hours, 10)
|
|
if err != nil {
|
|
fmt.Println("All is lost")
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Println("\nHourly wage: ", wage_int)
|
|
fmt.Println("Total number of hours: ", hours_int)
|
|
|
|
fmt.Printf("\nDollars earned per second: \n\t %.3f", (wage_int/60)/60)
|
|
fmt.Printf("\nDollars earned per minute: \n\t %.3f", (wage_int / 60))
|
|
fmt.Printf("\nDollars earned per hour: \n\t %.3f", wage_int)
|
|
fmt.Printf("\nAverage dollars earned per day: \n\t %.3f", (wage_int*hours_int)/7)
|
|
fmt.Printf("\nDollars earned per week: \n\t %.3f", (wage_int * hours_int))
|
|
fmt.Printf("\nAverage dollars earned per month: \n\t %.3f", (wage_int*hours_int*52)/12)
|
|
fmt.Printf("\nYearly pay: \n\t %.3f \n", (wage_int * hours_int * 52))
|
|
|
|
}
|
|
|
|
// END MAIN
|
|
func input(s string) (string, error) {
|
|
stdin_buf := bufio.NewReader(os.Stdin)
|
|
|
|
fmt.Print(s)
|
|
|
|
text, err := stdin_buf.ReadString('\n')
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return text[:len(text)-1], err
|
|
}
|