Files
noahspan-go/profitCalculator/app.go
2024-10-18 10:01:50 +00:00

30 lines
657 B
Go

package main
import "fmt"
func main() {
revenue := getUserInput("Revenue: ")
expenses := getUserInput("Expenses: ")
taxRate := getUserInput("Tax Rate: ")
ebt, profit, ratio := calculateFinancials(revenue, expenses, taxRate)
fmt.Printf("%.1f\n", ebt)
fmt.Printf("%.1f\n", profit)
fmt.Printf("%.3f", ratio)
}
func calculateFinancials(revenue, expenses, taxRate float64) (float64, float64, float64) {
ebt := revenue - expenses
profit := ebt * (1 - taxRate/100)
ratio := ebt / profit
return ebt, profit, ratio
}
func getUserInput(infoText string) float64 {
var userInput float64
fmt.Print(infoText)
fmt.Scan(&userInput)
return userInput
}