Floating point number

Report a typo

You get a number by the input. It's a really big floating point number. You need to check if the number is correct. Let's assume that the correct floating point number is:

  • contain a dot symbol "." (not the comma ",");
  • contain only one dot symbol.

If the number is correct, you need to print a message — correct. In another way, print the message about the first error:

  • comma detected
  • multiple dot symbols

Tip: The strings.Count() method can help you to count a number of dots.

Sample Input 1:

100500.100500100500.

Sample Output 1:

multiple dot symbols
Write a program in Go
package main

import (
"fmt"
"strings"
)

func main() {
var input string
fmt.Scan(&input)

switch {
case strings.?:
fmt.Println("comma detected")
case ? > 1:
fmt.Println("multiple dot symbols")
default:
fmt.Println("correct")
}
}
___

Create a free account to access the full topic