You are on page 1of 2

CP190 – Programming Fundamentals

Lab 6
Starting to code in C#

Instructions
Name the project Lab6

At the top of this file, comment it with

 First official C# Lab


 the name of this lab
 your name
 today’s date

Details
1. Display “We are in a brave new world” in the console
2. Create a string variable called response
3. Ask the user for their name and store it in the response variable
4. Display “Welcome to C#”, response
5. Create a variable to hold a whole number, myNumber
6. Ask the user for a number between 1 and 20 and store it in the response variable
7. Convert the response into a number and store in the variable created in step 5
8. Multiply myNumber by itself and store in another variable
9. Display myNumber, “ squared = “, variableFromStep8
10. Ask the user for a type of pet
a. If the pet is “cat”, display “Feline”
b. If the pet is “dog”, display “Canine”
c. If the pet is “dragon”, display “Cool!”
d. Otherwise display pet, “ is a fun pet”
11. Ask the user for another number
12. Create Boolean variables isEven and isASeven
13. If the number is even set isEven to true, otherwise set it to false
a. remember, it is even if when divided by 2 there is a remainder of 0
14. Set isASeven to whether or not the number is divisible by 7
15. Using if/else ifs…
a. If the number is divisible by 7 and is even, then display number, “ is an EVEN multiple of
seven”
b. If the number is divisible by 7 and is odd, then display number, “ is a multiple of 7 and is
ODD”
c. If the number is even then display “This number (”, number, “) is an even number, but
not divisible by seven”
d. Otherwise display number, “ is an odd number”
16. Use a for loop and display “I think I can…” 6 times
17. Create a Boolean variable shouldRepeat
18. Create a while loop
a. We will loop while shouldRepeat is true
b. Display “Hello world”
c. Display “Want me to repeat myself (y/n)”
d. Get the answer from the user
e. We will keep repeating as long as the answer is not a N or n
f. Make sure your code will enter into this loop the first time

Finally
Follow the slide deck for how to submit this C# project

You might also like