Write a user defined method named displayDetails() that declared and assigns values to local variables for your nick name, your student number, and your favourite movie. The method should also contain 3 WriteLine statements to display your nick name, your student number, and your favourite movie. Write a program that displays the text Hello World and then calls the displayDetails() method to display your information
using System;
namespace Test
{
class DisplayTest
{
static void displayDetails()
{
Console.Write("Enter your nick name: ");
string nickName = Console.ReadLine();
Console.Write("Enter your student number: ");
string studentNumber = Console.ReadLine();
Console.Write("Enter your favorite movie: ");
string favoriteMovie = Console.ReadLine();
Console.WriteLine("\n" + nickName);
Console.WriteLine(studentNumber);
Console.WriteLine(favoriteMovie);
}
static int Main()
{
Console.WriteLine("Hello World\n");
displayDetails();
return 0;
}
}
}
Comments
Leave a comment