File tree 2 files changed +47
-0
lines changed
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "bufio"
5
+ "fmt"
6
+ "os"
7
+ )
8
+
9
+ func main () {
10
+ welcome := "Welcome to the user input"
11
+ fmt .Println (welcome )
12
+
13
+ reader := bufio .NewReader (os .Stdin )
14
+ fmt .Println ("Enter the rating of our pizza: " )
15
+
16
+ input , _ := reader .ReadString ('\n' )
17
+ fmt .Println ("Thanks for rating, " , input )
18
+ fmt .Printf ("Type of this rating is %T " , input )
19
+ }
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "bufio"
5
+ "fmt"
6
+ "os"
7
+ "strconv"
8
+ "strings"
9
+ )
10
+
11
+ func main () {
12
+ welcome := "Welcome to the user input"
13
+ fmt .Println (welcome )
14
+
15
+ reader := bufio .NewReader (os .Stdin )
16
+ fmt .Println ("Enter the rating of our pizza: " )
17
+
18
+ input , _ := reader .ReadString ('\n' )
19
+ fmt .Println ("Thanks for rating!, " , input )
20
+ numRating , err := strconv .ParseFloat (strings .TrimSpace (input ), 64 )
21
+
22
+ if err != nil {
23
+ fmt .Println (err )
24
+ } else {
25
+ fmt .Println ("Added 1 to your rating: " , numRating + 1 )
26
+ }
27
+
28
+ }
You can’t perform that action at this time.
0 commit comments