|
| 1 | +// 1 -) Iki rakam arasında toplama, çıkarma ve çarpma |
| 2 | +// işleminin yapıldığı bir fonkiyon yazınız. |
| 3 | + |
| 4 | +/* package main |
| 5 | +
|
| 6 | +import "fmt" |
| 7 | +
|
| 8 | +func main() { |
| 9 | +
|
| 10 | + x, y := 10, 4 |
| 11 | + sum1, dif1, prod1 := calculation(x, y) |
| 12 | + fmt.Println("Toplam: ", sum1) |
| 13 | + fmt.Println("Fark: ", dif1) |
| 14 | + fmt.Println("Çarpım: ", prod1) |
| 15 | +
|
| 16 | +} |
| 17 | +
|
| 18 | +func calculation(num1, num2 int) (int, int, int) { |
| 19 | + sum := num1 + num2 |
| 20 | + dif := num1 - num2 |
| 21 | + prod := num1 * num2 |
| 22 | +
|
| 23 | + return sum, dif, prod |
| 24 | +} */ |
| 25 | + |
| 26 | +// 2 -) Kullanıcı tarafından girilen nota göre geçtiniz |
| 27 | +// veya kaldınız geri dönüşünü yazdırınız. |
| 28 | + |
| 29 | +/* package main |
| 30 | +
|
| 31 | +import ( |
| 32 | + "bufio" |
| 33 | + "fmt" |
| 34 | + "os" |
| 35 | + "strconv" |
| 36 | + "strings" |
| 37 | +) |
| 38 | +
|
| 39 | +func main() { |
| 40 | +
|
| 41 | + fmt.Print("Lütfen aldığınız notu giriniz: ") |
| 42 | + grade, _ := getGrade() |
| 43 | +
|
| 44 | + var result string |
| 45 | +
|
| 46 | + if grade >= 50 { |
| 47 | + result = "Geçtin" |
| 48 | + } else { |
| 49 | + result = "Kaldın" |
| 50 | + } |
| 51 | +
|
| 52 | + fmt.Println(result) |
| 53 | +
|
| 54 | +} |
| 55 | +
|
| 56 | +func getGrade() (int, error) { |
| 57 | + reader := bufio.NewReader(os.Stdin) |
| 58 | +
|
| 59 | + input, err := reader.ReadString('\n') |
| 60 | + if err != nil { |
| 61 | + fmt.Println(err) |
| 62 | + } |
| 63 | +
|
| 64 | + input = strings.TrimSpace(input) |
| 65 | + num, err := strconv.Atoi(input) |
| 66 | + if err != nil { |
| 67 | + fmt.Println(err) |
| 68 | + } |
| 69 | +
|
| 70 | + return num, nil |
| 71 | +} */ |
| 72 | + |
| 73 | +// 3 -) 1 ile yüz arasındaki bir sayıyı tahmin etme uygulaması |
| 74 | +// yazınız. Toplam tahmin hakkınız 10 olsun. |
| 75 | + |
| 76 | +package main |
| 77 | + |
| 78 | +import ( |
| 79 | + "bufio" |
| 80 | + "fmt" |
| 81 | + "math/rand" |
| 82 | + "os" |
| 83 | + "strconv" |
| 84 | + "strings" |
| 85 | + "time" |
| 86 | +) |
| 87 | + |
| 88 | +func main() { |
| 89 | + |
| 90 | + target := numRand(1, 100) |
| 91 | + |
| 92 | + fmt.Println("1 ile 100 arasındaki sayıyı bulmaya çalışın") |
| 93 | + |
| 94 | + reader := bufio.NewReader(os.Stdin) |
| 95 | + |
| 96 | + for attempts := 0; attempts < 10; attempts++ { |
| 97 | + fmt.Println(10-attempts, "hakkınız kaldı") |
| 98 | + fmt.Print("Lütfen tahmininizi yapınız: ") |
| 99 | + |
| 100 | + input, err := reader.ReadString('\n') |
| 101 | + if err != nil { |
| 102 | + fmt.Println(err) |
| 103 | + } |
| 104 | + |
| 105 | + input = strings.TrimSpace(input) |
| 106 | + num, err := strconv.Atoi(input) |
| 107 | + if err != nil { |
| 108 | + fmt.Println(err) |
| 109 | + } |
| 110 | + |
| 111 | + if num > target { |
| 112 | + fmt.Println("Tahmininiz daha büyük, daha küçük bir sayı giriniz.") |
| 113 | + } else if num < target { |
| 114 | + fmt.Println("Tahmininiz daha küçük, daha büyük bir sayı giriniz.") |
| 115 | + } else { |
| 116 | + fmt.Println("Doğru Tahmin, hedf sayı ", target, " idi ", attempts, " seferde bulundunuz") |
| 117 | + break |
| 118 | + } |
| 119 | + |
| 120 | + } |
| 121 | + |
| 122 | +} |
| 123 | + |
| 124 | +func numRand(min, max int) int { |
| 125 | + rand.Seed(time.Now().Unix()) |
| 126 | + return rand.Intn(max-min) + min |
| 127 | +} |
| 128 | + |
| 129 | +// ------------------------------------- |
| 130 | + |
| 131 | +/* package main |
| 132 | +
|
| 133 | +import ( |
| 134 | + "bufio" |
| 135 | + "fmt" |
| 136 | + "os" |
| 137 | +) |
| 138 | +
|
| 139 | +func main() { |
| 140 | +
|
| 141 | + fmt.Print("Lütfen Sınav Sonucunuzu Giriniz: ") |
| 142 | + reader := bufio.NewReader(os.Stdin) |
| 143 | + value, _ := reader.ReadString('\n') |
| 144 | + fmt.Println(value) |
| 145 | +} */ |
| 146 | + |
| 147 | +/* package main |
| 148 | +
|
| 149 | +import ( |
| 150 | + "bufio" |
| 151 | + "fmt" |
| 152 | + "os" |
| 153 | + "strconv" |
| 154 | + "strings" |
| 155 | +) |
| 156 | +
|
| 157 | +func main() { |
| 158 | +
|
| 159 | + fmt.Print("Lütfen Celcius derecesi giriniz: ") |
| 160 | + celcius, _ := getCelcius() |
| 161 | +
|
| 162 | + fahrenheit := (celcius * 9 / 5) + 32 |
| 163 | +
|
| 164 | + fmt.Println(fahrenheit, "Fahrenheit derecedir.") |
| 165 | +
|
| 166 | +} |
| 167 | +
|
| 168 | +func getCelcius() (int, error) { |
| 169 | + reader := bufio.NewReader(os.Stdin) |
| 170 | +
|
| 171 | + input, err := reader.ReadString('\n') |
| 172 | + if err != nil { |
| 173 | + fmt.Println(err) |
| 174 | + } |
| 175 | +
|
| 176 | + input = strings.TrimSpace(input) |
| 177 | + num, err := strconv.Atoi(input) |
| 178 | + if err != nil { |
| 179 | + fmt.Println(err) |
| 180 | + } |
| 181 | +
|
| 182 | + return num, nil |
| 183 | +} |
| 184 | +*/ |
| 185 | + |
| 186 | +/* package main |
| 187 | +
|
| 188 | +import ( |
| 189 | + "bufio" |
| 190 | + "fmt" |
| 191 | + "os" |
| 192 | + "strconv" |
| 193 | + "strings" |
| 194 | +) |
| 195 | +
|
| 196 | +func main() { |
| 197 | +
|
| 198 | + fmt.Print("Lütfen Celcius derecesi giriniz: ") |
| 199 | + celcius, _ := getCelcius() |
| 200 | +
|
| 201 | + kelvin := celcius + 273 |
| 202 | +
|
| 203 | + fmt.Println(kelvin, "Kelvin derecedir.") |
| 204 | +
|
| 205 | +} |
| 206 | +
|
| 207 | +func getCelcius() (int, error) { |
| 208 | + reader := bufio.NewReader(os.Stdin) |
| 209 | +
|
| 210 | + input, err := reader.ReadString('\n') |
| 211 | + if err != nil { |
| 212 | + fmt.Println(err) |
| 213 | + } |
| 214 | +
|
| 215 | + input = strings.TrimSpace(input) |
| 216 | + num, err := strconv.Atoi(input) |
| 217 | + if err != nil { |
| 218 | + fmt.Println(err) |
| 219 | + } |
| 220 | +
|
| 221 | + return num, nil |
| 222 | +} |
| 223 | +*/ |
| 224 | + |
| 225 | +/* package main |
| 226 | +
|
| 227 | +import ( |
| 228 | + "greeting" |
| 229 | +) |
| 230 | +
|
| 231 | +func main() { |
| 232 | + greeting.Hello() |
| 233 | + greeting.Hi() |
| 234 | + greeting.Allgreet() |
| 235 | +
|
| 236 | +} |
| 237 | +
|
| 238 | +*/ |
| 239 | + |
| 240 | +/* package main |
| 241 | +
|
| 242 | +import ( |
| 243 | + "fmt" |
| 244 | + "getcelcius" |
| 245 | +) |
| 246 | +
|
| 247 | +func main() { |
| 248 | +
|
| 249 | + fmt.Print("Lütfen Celcius derecesi giriniz: ") |
| 250 | + celcius, _ := getcelcius.GetCelcius() |
| 251 | +
|
| 252 | + kelvin := celcius + 273 |
| 253 | +
|
| 254 | + fmt.Println(kelvin, "Kelvin derecedir.") |
| 255 | +
|
| 256 | +} */ |
0 commit comments