/*---------------------------------------------------------
Description:
Demonstrates how to represent and display currency
values in idiomatic Go using formatted output.
---------------------------------------------------------*/
package main
import (
"fmt"
)
func main() {
// Price and tax rate
price := 199.99
taxRate := 0.17 // 17%
// Calculate tax and total
taxAmount := price * taxRate
total := price + taxAmount
// Output with $ and % signs
fmt.Printf("Price: $%.2f\n", price)
fmt.Println("Tax Rate: 17%")
fmt.Printf("Tax Amount: $%.2f\n", taxAmount)
fmt.Printf("Total: $%.2f\n", total)
}
/*
run:
Price: $199.99
Tax Rate: 17%
Tax Amount: $34.00
Total: $233.99
*/