├── .github └── FUNDING.yml ├── .vscode └── settings.json ├── LICENSE ├── README.md └── test └── main.go /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | 14 | /* */ 15 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | {} 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Nika Shamiladze 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # calculatorgo 2 | I am trying to create a calculator on Go. I am a beginner and I think it will be a good challenge 3 | -------------------------------------------------------------------------------- /test/main.go: -------------------------------------------------------------------------------- 1 | package main; 2 | 3 | import ( 4 | "fmt" 5 | "bufio" 6 | "os" 7 | "strconv" 8 | ) 9 | 10 | func main() { 11 | count := false; 12 | // scanner := bufio.NewScanner(os.Stdin); 13 | // scanner.Scan() 14 | // input, _ := strconv.ParseInt(scanner.Text(), 10, 64); 15 | // fmt.Printf("You typed: %d", 2020-input); 16 | 17 | // first scanner to identify username 18 | fmt.Println("Hello, What's your name?"); 19 | scanner := bufio.NewScanner(os.Stdin); 20 | scanner.Scan() 21 | input := scanner.Text() 22 | 23 | if input != "" && input != " " { 24 | // second scanner to continue [Y/N] 25 | fmt.Println(input + ", " + "You Want Continue? [Y/N]"); 26 | continueScanner := bufio.NewScanner(os.Stdin) 27 | continueScanner.Scan() 28 | continueInput := continueScanner.Text() 29 | if continueInput == "Y" || continueInput == "y" { 30 | /* Continue Calculator Section */ 31 | if count != true { 32 | fmt.Printf("Choose Operator (+, -, *, /, %, \n"); 33 | chooseOperator := bufio.NewScanner(os.Stdin); 34 | chooseOperator.Scan() 35 | chi := chooseOperator.Text(); 36 | if chi != "" && chi != " " { 37 | fmt.Printf("You want to show enter result? [Y/N] \n"); 38 | sr := bufio.NewScanner(os.Stdin); 39 | sr.Scan() 40 | sri := sr.Text() 41 | fmt.Printf("You Choose: " + sri + "\n"); 42 | 43 | if sri == "Y" || sri == "y" || sri == "n" || sri == "N" { 44 | // component to building calc; 45 | // first number enter; 46 | firstNumberScanner := bufio.NewScanner(os.Stdin) 47 | fmt.Printf("Please enter a first number \n"); 48 | firstNumberScanner.Scan() 49 | fnsi, _ := strconv.ParseInt(firstNumberScanner.Text(), 10, 64); 50 | if sri == "n" || sri == "N" { 51 | // empty; 52 | } else { 53 | fmt.Println(fnsi); 54 | } 55 | // second number enter; 56 | fmt.Printf("Please enter a second number \n"); 57 | secondNumberScanner := bufio.NewScanner(os.Stdin); 58 | secondNumberScanner.Scan() 59 | snsi, _ := strconv.ParseInt(secondNumberScanner.Text(), 10, 64); 60 | if sri == "n" || sri == "N" { 61 | // empty; 62 | } else { 63 | fmt.Println(snsi); 64 | } 65 | switch chi { 66 | case "+": 67 | z := fnsi + snsi; 68 | fmt.Println(z); 69 | break; 70 | case "-": 71 | z := fnsi - snsi; 72 | fmt.Println(z); 73 | break; 74 | case "*": 75 | z := fnsi * snsi; 76 | fmt.Println(z); 77 | break; 78 | case "/": 79 | z := fnsi / snsi; 80 | fmt.Println(z); 81 | break; 82 | case "%": 83 | z := fnsi % snsi; 84 | fmt.Println(z); 85 | break; 86 | default: 87 | z := "choose bad format error"; 88 | fmt.Printf(z); 89 | } 90 | } else { 91 | fmt.Printf("That's bad choose format " + sri + " bye."); 92 | } 93 | 94 | // fmt.Printf(input + ", " + "Please Enter a first number"); 95 | } else { 96 | fmt.Println("You Choose " + chi + " and that's bad choose format bye."); 97 | } 98 | } 99 | } else if continueInput == "N" || continueInput == "n" { 100 | fmt.Printf("You Choose: " + continueInput + " Thanks for using calculator"); 101 | } else { 102 | fmt.Printf("That's bad choose format " + continueInput + " Bye."); 103 | } 104 | } else { 105 | fmt.Println("Please type your name"); 106 | } 107 | 108 | // fmt.Printf("You Want Continue? [Y/N]"); 109 | // inpScanner := bufio.NewScanner(os.Stdin); 110 | // inpScanner.Scan() 111 | // inp := inpScanner.Text() 112 | // fmt.Printf(inp); 113 | } 114 | --------------------------------------------------------------------------------