Capitals
Consider the following program capitals.go that reads a line of text from standard input and outputs the line of text all capitalized.
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
var s string
const BASE_LOWER = ’a’
const BASE_UPPER = ’A’
scanner := bufio.NewScanner(os.Stdin)
fmt.Println("Enter a string to be converted to uppercase:")
if scanner.Scan() {
s = scanner.Text()
}
fmt.Println("The string's length is", len(s))
for _, char := range s {
if char >= ’a’ && char <= ’z’ {
n := char - BASE_LOWER
char = BASE_UPPER + n
}
fmt.Print(string(char))
}
fmt.Println()
}Analyze the source code and answer the following questions.
- Through which channel does the program receive the data to be processed?
- What type are the input data?
- Are the input data ready to be processed or are they first preprocessed in order to compute/extract other data?
