https://github.com/truecodersio/selection-statements-exercise
.NET 6.0 template project for the Selection Statements exercise at TrueCoders
https://github.com/truecodersio/selection-statements-exercise
Last synced: about 1 year ago
JSON representation
.NET 6.0 template project for the Selection Statements exercise at TrueCoders
- Host: GitHub
- URL: https://github.com/truecodersio/selection-statements-exercise
- Owner: truecodersio
- Created: 2022-09-06T18:38:53.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-28T15:29:56.000Z (over 1 year ago)
- Last Synced: 2025-04-06T15:13:29.077Z (over 1 year ago)
- Language: C#
- Size: 88.9 KB
- Stars: 0
- Watchers: 2
- Forks: 422
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Exercise 1:
Create a program that allows a user to play a game where they must guess what your favorite number is:
* Initialize an integer to represent a favorite number and assign a value with a number of your choosing or you can assign a random number to this variable:
```
var r = new Random();
var favNumber = r.Next(1,1000);
var userInput = int.Parse(Console.ReadLine());
```
The following code will allow the user to guess what your favorite number is:
```
var userInput = int.Parse(Console.ReadLine());
```
+ Create an if-statement that if the guessed number is below the initial value, print out “too low”.
+ Create an else-if statement that if the number is higher than the initial value, print out “too high”.
+ Create an else statement that prints out some type of congratulations for guessing the correct number e.g. “You guessed it!!!”.
Remember to save, commit, and push back to Github once complete
## Extra Switch Statement Practice:
[https://www.codewars.com/kata/568dc014440f03b13900001d/train/csharp](https://www.codewars.com/kata/568dc014440f03b13900001d/train/csharp)