Skip to content

Instantly share code, notes, and snippets.

@dmsl1805
Forked from 726f737479/gist:4220a55a16de0171b279e362c6227e83
Last active January 28, 2025 14:15
Show Gist options
  • Save dmsl1805/5557e478a44437e2b103bc9c1851f355 to your computer and use it in GitHub Desktop.
Save dmsl1805/5557e478a44437e2b103bc9c1851f355 to your computer and use it in GitHub Desktop.
Kotlin
package main
import "fmt"
func drawRating(vote int) string {
if vote >= 0 && vote <= 20 {
return "★☆☆☆☆"
} else if vote > 20 && vote <= 40 {
return "★★☆☆☆"
} else if vote > 40 && vote <= 60 {
return "★★★☆☆"
} else if vote > 60 && vote <= 80 {
return "★★★★☆"
} else if vote > 80 && vote <= 100 {
return "★★★★★"
} else {
return "☆☆☆☆☆"
}
}
func main() {
fmt.Println(drawRating(0)) // ★☆☆☆☆
fmt.Println(drawRating(1)) // ★☆☆☆☆
fmt.Println(drawRating(50)) // ★★★☆☆
fmt.Println(drawRating(99)) // ★★★★★
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment