You are a Windows developer for a data analysis company. For one of your applications you need to create a keyword searching form that asks for a filename and a keyword from the user (as shown in below figure). The form should search for the keyword in the file and display the number of lines that contain the keyword in the results group box. Your form assumes that the entered keyword is a single word. If it is not a single word, you need to create and throw an exception for that case.
using System;
namespace WhatsMyInfo
{
public class Program
{
public static void Main()
{
string name;
int age;
int birthyear;
Console.Write("Please enter your name: ");
name = Console.ReadLine();
Console.Write("Please enter your age: ");
age = Convert.ToInt32(Console.ReadLine());
Console.Write("What year were you born?: ");
birthyear = Convert.ToInt32(Console.ReadLine());
//Print a blank line
Console.WriteLine();
//Show the details that the user entered
Console.WriteLine("Name is {0}.", name);
Console.WriteLine("Age is {0}.", age);
Console.WriteLine("Birth year is {0}.", birthyear);
}
}
}
Comments
Leave a comment