EASY getMonthlyPrice Assignment

Complete the getMonthlyPrice function. It accepts a tier (string) as input and returns the monthly price for that tier in pennies. Here are the prices in dollars:

  • "basic" - $100.00

  • "premium" - $150.00

  • "enterprise" - $500.00

Convert the prices from dollars to pennies. If the given tier doesn't match any of the above, return 0 pennies.

package main

func getMonthlyPrice(tier string) int {
	const pennyConversion = 100
	const basicPlan = 100.00
	const premiumPlan = 150.00
	const enterprisePlan = 500.00

	if tier == "basic"{
		return int(basicPlan * pennyConversion)
	} else if tier == "premium" {
		return int(premiumPlan * pennyConversion)
	} else if tier == "enterprise" {
		return int(enterprisePlan * pennyConversion)
	} else{
		return 0
	}
	
}