From deeee2abc2f93365e17ed2871139432cfb3ee18e Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 8 May 2026 13:33:25 +0000 Subject: [PATCH] [Sync Iteration] go/vehicle-purchase/1 --- .../go/vehicle-purchase/1/vehicle_purchase.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 solutions/go/vehicle-purchase/1/vehicle_purchase.go diff --git a/solutions/go/vehicle-purchase/1/vehicle_purchase.go b/solutions/go/vehicle-purchase/1/vehicle_purchase.go new file mode 100644 index 0000000..6c09298 --- /dev/null +++ b/solutions/go/vehicle-purchase/1/vehicle_purchase.go @@ -0,0 +1,32 @@ +package purchase +import "fmt" +// NeedsLicense determines whether a license is needed to drive a type of vehicle. Only "car" and "truck" require a license. +func NeedsLicense(kind string) bool { + if kind == "car" || kind == "truck" { + return true + } + return false +} + +// ChooseVehicle recommends a vehicle for selection. It always recommends the vehicle that comes first in lexicographical order. +func ChooseVehicle(option1, option2 string) string { + if option1 < option2 { + return fmt.Sprintf( "%s is clearly the better choice.", option1) + } + return fmt.Sprintf( "%s is clearly the better choice.", option2) +} + +// CalculateResellPrice calculates how much a vehicle can resell for at a certain age. +func CalculateResellPrice(originalPrice, age float64) float64 { + if age < 3 { + return originalPrice - discount(originalPrice,0.2) + } else if age >= 3 && age < 10 { + return originalPrice - discount(originalPrice,0.3) + } else{ + return originalPrice - discount(originalPrice,0.5) + } +} + + func discount(price float64, discountPercent float64) float64 { + return price * discountPercent + } \ No newline at end of file