1 ONLY VISUAL STUDIO C CONSOLE APPLIACTION NO JAVA CODING In

1. ONLY VISUAL STUDIO C# CONSOLE APPLIACTION

(NO JAVA CODING)

In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P1. For example a student with first name John and Last name Smith would name the project A3JohnSmithP1.


You are creating a console based math program. This program will be shown as a menu with several options. The menu should be created with a do loop.
The first option is to display a list of even numbers beginning at 0. Once this option is selected, the program asks the user for the number of even numbers to display. After the user provides this input, all the values should be displayed at once. This option should be created using a \"for\" loop.


The second option is to display a sequence of perfect squares. The program should begin by printing the square of 1, and ask the user if they to continue or stop and return to the original menu. If the user does not want to quit, the next square is printed. This continues until the user wishes to end the sequence. This option should be created using a while loop.


The third option is to exit the program. Any invalid option entered by the user should prompt the menu to reappear and ask the same three options.
Any numeric entry by the user should not crash if the user enters a string.
Your program must:
a. Use the appropriate loop for each segment. [3 marks]
b. Encapsulate the logic of options 1 and 2 each within their own method. [4 marks]
c. The functionality of the menu is correct as described. [3 marks]
d. Proper error handling. [3 marks]
e. Adhere to coding standards as described by the course. Marks will be taken off wherever coding standards are not followed.

Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A3JohnSmithP1
{
class Program
{
static void Main(string[] args)
{
int n = 0;
string input=\"\";
do
{
Console.Clear();
Console.WriteLine(\"Select option according to your choice\ \");
Console.WriteLine(\"1. Print Even Number\");
Console.WriteLine(\"2. Print Sequence of Perfect Square\");
Console.WriteLine(\"3. Exit\");
try
{
input = Console.ReadLine();
switch (input)
{
case \"1\":
EvenNumGenFunc();
break;
case \"2\":
PerfSquareFunc();
break;
case \"3\": break;
default:Console.Clear();
Console.WriteLine(\"Please enter options within choice\");
Console.ReadLine();
break;
}
}
catch (Exception e)
{

}
} while (input != \"3\") ;

}

private static void EvenNumGenFunc()
{
try
{
int n,j=0;
Console.Clear();
Console.WriteLine(\"Énter the number of Even numbers to print\ \");
string input = Console.ReadLine();
bool isNumerical = int.TryParse(input, out n);
if (isNumerical)
{
for (int i = 0; i < n; i++)
{
j = j + 2;
Console.WriteLine(j);
}
}
else
{
Console.WriteLine(\"\ Please enter Integer Only\");
Console.ReadLine();
PerfSquareFunc();
  
}

}
catch (Exception ex1)
{


}
}

private static void PerfSquareFunc()
{
try
{
Console.Clear();
int i = 1;
int cont=0;
Console.WriteLine(i);
Console.WriteLine(\"Enter 0 to continue.. \ Any other key to exit\");
string input = Console.ReadLine();
while (input ==\"0\" && cont == 0)
{
Console.WriteLine(i * i);
cont = Int32.Parse(Console.ReadLine());
i++;
}
}
catch (Exception ex2)
{


}
}
}
}

1. ONLY VISUAL STUDIO C# CONSOLE APPLIACTION (NO JAVA CODING) In this part of the assignment, you are required to create a C# Console Application project. The p
1. ONLY VISUAL STUDIO C# CONSOLE APPLIACTION (NO JAVA CODING) In this part of the assignment, you are required to create a C# Console Application project. The p
1. ONLY VISUAL STUDIO C# CONSOLE APPLIACTION (NO JAVA CODING) In this part of the assignment, you are required to create a C# Console Application project. The p

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site