Getting input from our users
Having a program that is interactive with our users is priceless. But it also makes us need to test the information received to make sure that we can actually use it.
For example I may ask my user for their age, and instead of them giving me a number they may type in a word. this will break my program if I try and do math with a word.
In our first series of lessons we are going to pretend that our users are not actually trying to break our program.... you will learn how to test the data to make sure that it is what we want, but for now we are not going to worry about it.
For example I may ask my user for their age, and instead of them giving me a number they may type in a word. this will break my program if I try and do math with a word.
In our first series of lessons we are going to pretend that our users are not actually trying to break our program.... you will learn how to test the data to make sure that it is what we want, but for now we are not going to worry about it.
The Video
The Assignment
Using the information in the videos above, make a simple calculator.
1. Ask the user for their name using Console.Write
example... Hello, what is your name?
2. Ask them for 2 different numbers using Console.Write and Console.Readline
example... Please input a number
Please input a second number
3. Using a Console.WriteLine tell your user what data they put in. Include their name and their two numbers.
example... "Thank you Simon, the two numbers that you put in are 7 and 14.
4. Then output three lines of text to the screen. The three lines should show the user what their numbers look like; Added together, Subtracted from one another, and Multiplied together
example... You two numbers added together are 7+14 = 21
Your numbers Subtracted from each other are 7 - 14 = -7
Your numbers Multiplied together are 7 * 14 = 98
5. Finish your program with a greeting
example... Thank you for using this program today. Good bye
1. Ask the user for their name using Console.Write
example... Hello, what is your name?
2. Ask them for 2 different numbers using Console.Write and Console.Readline
example... Please input a number
Please input a second number
3. Using a Console.WriteLine tell your user what data they put in. Include their name and their two numbers.
example... "Thank you Simon, the two numbers that you put in are 7 and 14.
4. Then output three lines of text to the screen. The three lines should show the user what their numbers look like; Added together, Subtracted from one another, and Multiplied together
example... You two numbers added together are 7+14 = 21
Your numbers Subtracted from each other are 7 - 14 = -7
Your numbers Multiplied together are 7 * 14 = 98
5. Finish your program with a greeting
example... Thank you for using this program today. Good bye