Introduction: In this Unit I will be learning how to code in C# and be able to make programs that can ask for your name age and that I can code programs that can do calculations.

Task 1: Write a C# sharp programme that displays your name on one line.

Task 2: Write a C# sharp program that prints the sum of two numbers

Task 3: Write a C# program that prints the result of diving two numbers.

Task 4: Write a C# sharp program that prints the results of specified operations

Task 5:Write a C# code that remembers a whole number known as an integer, Int for short.

Task 6: Write C# code that uses 2 numbers for a sum and formats output onto the screen.

Task 7:Write C# code that gets numbers from the keyboard. There needs to be numbers in input for it to work and to the calculation.


Task 8: Write a C# sharp program to print on the screen the output of adding subtracting multiplying and dividing of two numbers which will be entered by the user.


Task 9: Write a C# sharp program that takes an age as an input and prints something as “You look older than 18”.


DIY Task: Write C# code that displays your full name, asks what year you were born and e.g.2000 and asks for the current year e.g. 2020. The application should display your name the year born and current year and calculate and display how old you are in years.

DIY Task 1 Evidence
Task: Write C# code that displays your full name, askes what year you were born and e.g.2000 and askes for the current year e.g. 2020. The application should display your name the year born and current year and calculate and display how old you are in years. Upload slot on Moodle |
Code: In the screenshot. |
Problems: I had problems with learning how to create the calculation and deciding how the code would calculate the age but eventually I found out a way of doing it. through coming up with the method that the user enters what year it is and what year they were born and takeaway from each other to give you your age. |
Research: Another method of calculating the age of someone through a program is to use the date of birth like 1988/12/20 first comes years months then days. You enter your date of birth in that format and program the program finds out what the date and time are now and calculates the difference from your date of birth to the current time and returns the answer years then months days and hour. Reference:[Pratap Shahi, U., 2021.] How to Calculate Age from Date of Birth in C#. [online] C-sharpcorner.com. Available at: <https://www.c-sharpcorner.com/code/961/how-to-calculate-age-from-date-of-birth-in-c-sharp.aspx> [Accessed 11 February 2021]. |
Evaluation: My code is good but could be improved as it relies on you inputting the current year and the year you were born and it takes them away from each other to find out your age. My code is ok but it can be better and shorter with a different method of solving on how you calculate the find your age. |
Task 1: Write C# code that prints your name and age on the screen.

Task 2: Write C# code that prints your name and age on the screen using an int and a string

Task 3:– Write C# code that gets user input for age and name, prints your name and age on the screen using an int and a string (NOTE: you must use the input tab anywhere you have a ReadLine.


Task 4: Write a C# code that gets the user to enter their age and it decides if you are 18.


Task 5:Change the value of yourAge in task 4 above to 10 and run it. What is the output? Change the value of yourAge again to 33. What is the output?


Task 6: Write C# code that gets user input for age and decides if you are 18 or over. Test this code with input of 10, then 18 and finally 33


Task 7:Task 7: – Write C# code that gets user input for age and decides if you are 18 or under. Test this code with input of 10, then 18 and finally 33


Task 8: Change the test in the line of code if(yourAge<=18) in the code for task 7. Try running it with the following

Task 9: Task 9: Change the value of the test from task 7 code from 18 to another number, try 10, 16, 19 and 33. What is happening and why?
It changes the age limit of the answer so I used 33 and if you input a number higher than 33 then it outputs the answer “you are 33 or older”)

Task 10: Write C# code that test 2 or more values (PS the | is above my backslash key)

DIY task 2


Task: Develop C# code that asks for a user Age as an int data type. this is then used in 3 statements and tests · Age is greater then 0 and less then 5, and outputs “infant” · Age is greater then 5 but less then or equal to 16, and outputs “school” · Age is greater then 16, and outputs “college |
Code: In the screenshot. |
Problems: I had problems with ages over 16 as the as it would output school and college however to fix this I wrote if(yourAge>=5) if(yourAge<=16) This helped me make the age range for school smaller and if the number was higher than 16 it did not output school and college. now if it’s under 16 and higher than 5 it only says “school”. |
Research: For research, I went into this form on how to the task and found that you can create a simple program using if and the < and > symbols. You can also use a different age range that will show different result and can change what the output would say. Reference:{w3resource. 2021]. C# Sharp exercises: Detrermine a specific age is eligible for casting the vote – w3resource. [online] Available at: <https://www.w3resource.com/csharp-exercises/conditional-statement/csharp-conditional-statement-exercise-5.php> [Accessed 11 February 2021]. |
Evaluation: What I have done is create a simple program that can output what school you would be in at that age I first struggled with a couple of lines and got frustrated with the code but then I slowly went through the code and changed the code so it would be correct and did some research to help me with the task. |
Overall now that I have finished the coding tasks I now know how to write code in C# Sharp code and can write programs in C# Sharp. I can write a program in C sharp to calculate someone’s name and age. The program can also determine what school they are in for their age. At the start, I found writing the code confusing but then as I understood how to write the code it appeared to be very simple and I was able to search online on how to do the projects. The problems I had at the start were spelling mistakes and errors in my code but when I slowly went through my code I saw the mistakes and changed them.