This commit is contained in:
2024-10-17 00:39:02 +00:00
parent d357447e78
commit 0d716f8255
4 changed files with 80 additions and 0 deletions

41
app.go
View File

@@ -0,0 +1,41 @@
package main
import "fmt"
import "math"
const inflationRate = 2.5
var investmentAmount float64
var years float64
var expectedReturnRate float64
func main() {
fmt.Print("Investment Amount: ")
fmt.Scan(&investmentAmount)
fmt.Print("Expected Return Rate: ")
fmt.Scan(&expectedReturnRate)
fmt.Print("Years: ")
fmt.Scan(&years)
futureValue := investmentAmount * math.Pow(1 + expectedReturnRate/100, years)
futureRealValue := futureValue / math.Pow(1 + inflationRate/100, years)
formattedFV := fmt.Sprintf("Future Value: %.1f\n", futureValue)
formattedRFV := fmt.Sprintf("Future Value (adjusted for inflation): %.1f\n", futureRealValue)
// fmt.Println("Future Value:", futureValue)
// fmt.Println("Future Value (adjusted for inflaction):", futureRealValue)
fmt.Print(formattedFV, formattedRFV)
}
func calculateFutureValues (investmentAmount, expectedFutureValue, years float64) (fv float64, rfv float64) {
fv = investmentAmount * math.Pow(1 + expectedReturnRate/100, years)
rfv = fv / math.Pow(1 + inflationRate/100, years)
return fv, rfv
}

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module example.com/investment-calculator
go 1.23.1

33
profitCalculator/app.go Normal file
View File

@@ -0,0 +1,33 @@
package main
import "fmt"
func main() {
var revenue float64
var expenses float64
var taxRate float64
fmt.Print("Revenue: ")
fmt.Scan(&revenue)
fmt.Print("Expenses: ")
fmt.Scan(&expenses)
fmt.Print("Tax Rate: ")
fmt.Scan(&taxRate)
ebt := revenue - expenses
profit := ebt * (1 - taxRate/100)
ratio := ebt / profit
fmt.Println(ebt)
fmt.Println(profit)
fmt.Println(ratio)
}
func getUserInput(infoText string) float64 {
var userInput float64
fmt.Print(infoText)
fmt.Scan(&userInput)
return userInput
}

3
profitCalculator/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module example.com/profit-calculator
go 1.23.1