Week 1
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: using System; public class Test { public static void Main() { Console.WriteLine(“Nils Slivackis”); int numberBox; int numberBox2; numberBox=Convert.ToInt32( Console.ReadLine()); numberBox2=Convert.ToInt32( Console.ReadLine()); Console.WriteLine(numberBox); Console.WriteLine(numberBox2); //Output 22 as text Console.WriteLine(“The Sum of {0} – {1} = {2}”,numberBox2,numberBox, (numberBox2-numberBox)); } } |
Problems: I didn’t really have any problems with this task it was pretty simple. |
Research:for research i didn’t need to do a lot because Robert gave us example codes that contained little bits of the code we needed so i just looked threw the practice codes and figured out what to do |
Evaluation: Although i don’t like coding for now it’s pretty simple |
Week 2
Task 2
using System;
public class Test
{
public static void Main()
{
string yourName = “Nils Slivackis”;
int yourAge=29;
Console.WriteLine(yourName);
Console.WriteLine(yourAge);
}
}
Task 3
using System;
public class Test
{
public static void Main()
{
string yourName;
int yourAge;
Console.WriteLine(“Nils Slivackis”);
yourName=Console.ReadLine();
Console.WriteLine(“19”);
yourAge=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Hi {0}”,yourName);
Console.WriteLine(“you are {0} years old”, yourAge);
}
}
Task 4
using System;
public class Test
{
public static void Main()
{
int yourAge;
Console.WriteLine(“Please enter your age”);
yourAge=Convert.ToInt32(Console.ReadLine());
if(yourAge==18);
{
Console.WriteLine(“You are {0} years old”,yourAge);
}
Console.WriteLine(“The End”);
}
}
Task 6
using System;
public class Test
{
public static void Main()
{
int yourAge;
Console.WriteLine(“pleas enter your age here”);
yourAge=Convert.ToInt32(Console.ReadLine());
if(yourAge>=18);
{
Console.WriteLine(“you are 18 or older”);
}
Console.WriteLine(“The end”);
}
}
Task: Develop C# code that uses asks for user Age as an int data type. This numbers then used in 3 if () statement and tests .Age is grater then 0 and less then 5, and output “infant” .Age is grater then 5 but less then or equal to 16, and outputs “school” .Age is greater then 16, and outputs “college” |
Code: using System; public class Test { public static void Main() { int myAge=4; if(myAge<5) { Console.WriteLine(“Infent”); }else if(myAge>=5 && myAge<=10) { Console.WriteLine(“School”); }else if(myAge>10 && myAge<=16) { Console.WriteLine("college"); } } } |
Problems: I had problems on figuring out how to write the code but after some research and help I figured it out |
Research: I looked at the task codes we had and in the end used to codes to make one and changed the “test point” to infant, school and college |
Evaluation: Once i figured out the code it was relatively easy to write only problems i ran it to during me typing it up was forgetting to but capital letters and some symbols. |