adding bank

This commit is contained in:
2024-10-18 10:01:50 +00:00
parent 0d716f8255
commit decb1a18a2
3 changed files with 73 additions and 14 deletions

View File

@@ -3,26 +3,23 @@ package main
import "fmt"
func main() {
var revenue float64
var expenses float64
var taxRate float64
revenue := getUserInput("Revenue: ")
expenses := getUserInput("Expenses: ")
taxRate := getUserInput("Tax Rate: ")
fmt.Print("Revenue: ")
fmt.Scan(&revenue)
ebt, profit, ratio := calculateFinancials(revenue, expenses, taxRate)
fmt.Print("Expenses: ")
fmt.Scan(&expenses)
fmt.Print("Tax Rate: ")
fmt.Scan(&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
fmt.Println(ebt)
fmt.Println(profit)
fmt.Println(ratio)
return ebt, profit, ratio
}
func getUserInput(infoText string) float64 {