Question

In: Computer Science

1. ONLY VISUAL STUDIO C# CONSOLE APPLIACTION (NO JAVA CODING) In this part of the assignment,...

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.

Solutions

Expert 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\n");
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\n");
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("\nPlease 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.. \n 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)
{


}
}
}
}


Related Solutions

ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this...
ONLY USE VISUAL STUDIO (NO JAVA CODING) VISUAL STUDIO -> C# -> CONSOLE APPLICATION In this part of the assignment, you are required to create a C# Console Application project. The project name should be A3<FirstName><LastName>P2. For example, a student with first name John and Last name Smith would name the project A1JohnSmithP2. Write a C# (console) program to calculate the number of shipping labels that can be printed on a sheet of paper. This program will use a menu...
answer the following using C# Design and program a Visual Studio Console project in C# that...
answer the following using C# Design and program a Visual Studio Console project in C# that allows your user to enter a number. The program will examine the number to see if it is prime. If it is prime, it will print the next higher prime and the next lower primes to the console. If the number entered by the user is not prime, display a message to that effect. All code should be written by you. Do not copy/paste...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of...
Create a C# .NET Core Console project in Visual Studio. (This is the same kind of project we have been doing all semester.) Do all of the following in the Program class. You do not need to add any other classes to this project. 2. If it exists, remove the Console.WriteLine(“Hello World!”); line that Visual Studio created in the Program class. 3. At the very top of the Program.cs page you should see using System; On the empty line below...
Create a Visual Studio console project (c++) containing a main() program that declares a const int...
Create a Visual Studio console project (c++) containing a main() program that declares a const int NUM_VALUES denoting the array size. Then declare an int array with NUM_VALUES entries. Using a for loop, prompt for the values that are stored in the array as follows: "Enter NUM_VALUES integers separated by blanks:" , where NUM_VALUES is replaced with the array size. Then use another for loop to print the array entries in reverse order separated by blanks on a single line...
Write a C program The Visual Studio project itself must make its output to the Console...
Write a C program The Visual Studio project itself must make its output to the Console (i.e. the Command Prompt using printf) and it must exhibit the following features as a minimum: 3%: Looping Menu with 3 main actions: View Cars, Sell Car, View Sales Note: A Car is defined by its price and model 3%: Must contain at least three arrays to record sales figures (maximum of 10 Car models) Two for recording the price and model of one...
Program coding for C# (Visual Studio) to move block up and down left to right. Simple...
Program coding for C# (Visual Studio) to move block up and down left to right. Simple harmonic motion
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2....
1. Make a Console App (.NET Core) in Visual Studio and name it as A1YourFirstnameLastname. 2. Implement a vehicle rental management system which is capable of doing the following: • View all, available and reserved vehicles. • Reserve vehicle or cancel a reservation. 3. The application must be menu-based app: 1 - View all vehicles 2 - View available vehicles 3 - View reserved vehicles 4 - Reserve a vehicle 5 - Cancel reservation 6 - Exit 4. NOTE: At...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You...
Make a Program in Visual Studio / Console App (.NET Framework) # language Visual Basic You will be simulating an ATM machine as much as possible Pretend you have an initial deposit of 1000.00. You will Prompt the user with a Main menu: Enter 1 to deposit Enter 2 to Withdraw Enter 3 to Print Balance Enter 4 to quit When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount....
Create a Visual Studio console project using c++ void lowerToUpper(std::string & sentence) that iterates over all...
Create a Visual Studio console project using c++ void lowerToUpper(std::string & sentence) that iterates over all characters in the sentence argument. Any lowercase letter should be converted to uppercase. This can be done by including <cctype> and testing each character in sentence with the islower() function. If islower(sentence[i]) returns true then sentence[i] should be replaced with toupper(sentence[i]). The main() function should assign "Hello how are you doing?" to sentence, call lowerToUpper(sentence), and use an if statement to check the new...
C++ Visual Studio 2019 Part A : Program Description: Write a program to generate a report...
C++ Visual Studio 2019 Part A : Program Description: Write a program to generate a report based on input received from a text file. Suppose the input text file student_grades.txt contains the student’s Last name , First name, SSN, Test1, Test2, Test3 and Test4. (25%) i.e. Alfalfa   Aloysius   123-45-6789 40.0    90.0   100.0    83.0 Generate the output Report File student_final.txt in the following format : LastName FirstName   SSN Test1   Test2   Test3   Test4 Average FinalGrade i.e. Alfalfa   Aloysius   123-45-6789 40.0    90.0   100.0   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT