Question

In: Computer Science

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 that add using System.Collections.Generic; This tells C# to include the generic collection namespace which contains the generic collection classes. 4. Create a private field named daysList which is a List containing the days of the week: Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday 5. Do the same thing as #2 for fields named daysDictionary, daysStack, and daysQueue which are Dictionary, Stack, and Queue respectively. For the dictionary use 0,1,2,3,4,5,6 as the keys. 6. Finally, use a foreach loop to iterate through one of the collections (you choose whichever one you want) and display that collection’s values to the screen.

Solutions

Expert Solution

The C# program is written as per the requirement. It is self-explanatory. As described in the requirements, there are collections declared, one each for storing the days of the week in List, Dictionary, Stack and Queue. The values are initialised within the main program.
A foreach loop is created to loop through the List and display the values on the screen.

Code

using System;
using System.Collections.Generic;

namespace Test
{
class Program
{
private static List<DayOfWeek> daysList = new List<DayOfWeek>(7);
private static Dictionary<int, DayOfWeek> daysDictionary = new Dictionary<int, DayOfWeek>(7);
private static Stack<DayOfWeek> daysStack = new Stack<DayOfWeek>(7);
private static Queue<DayOfWeek> daysQueue = new Queue<DayOfWeek>(7);

static void Main(string[] args)
{
//Add elements to the List
daysList.Add(DayOfWeek.Sunday);
daysList.Add(DayOfWeek.Monday);
daysList.Add(DayOfWeek.Tuesday);
daysList.Add(DayOfWeek.Wednesday);
daysList.Add(DayOfWeek.Thursday);
daysList.Add(DayOfWeek.Friday);
daysList.Add(DayOfWeek.Saturday);

//Add elements to the Dictionary
daysDictionary.Add(0, DayOfWeek.Sunday);
daysDictionary.Add(1, DayOfWeek.Monday);
daysDictionary.Add(2, DayOfWeek.Tuesday);
daysDictionary.Add(3, DayOfWeek.Wednesday);
daysDictionary.Add(4, DayOfWeek.Thursday);
daysDictionary.Add(5, DayOfWeek.Friday);
daysDictionary.Add(6, DayOfWeek.Saturday);

//Add elements to the stack
daysStack.Push(DayOfWeek.Sunday);
daysStack.Push(DayOfWeek.Monday);
daysStack.Push(DayOfWeek.Tuesday);
daysStack.Push(DayOfWeek.Wednesday);
daysStack.Push(DayOfWeek.Thursday);
daysStack.Push(DayOfWeek.Friday);
daysStack.Push(DayOfWeek.Saturday);

//Add elements to the Queue
daysQueue.Enqueue(DayOfWeek.Sunday);
daysQueue.Enqueue(DayOfWeek.Monday);
daysQueue.Enqueue(DayOfWeek.Tuesday);
daysQueue.Enqueue(DayOfWeek.Wednesday);
daysQueue.Enqueue(DayOfWeek.Thursday);
daysQueue.Enqueue(DayOfWeek.Friday);
daysQueue.Enqueue(DayOfWeek.Saturday);

//Loop through the Days List and print the values to the screen.
foreach (DayOfWeek day in daysList)
{
Console.WriteLine(day);
}

Console.Write("\nPress any key to continue");
Console.ReadKey();
}
}


}



Related Solutions

Create a C# console application (do not create a .NET CORE project) and name the project....
Create a C# console application (do not create a .NET CORE project) and name the project. Generate two random integers, each between 1 and 50, that you will be adding together to test the user's ability to perform the addition operator. Display the numbers in the console, such as:             7 + 22 = ? Once the user provides their answer, check to see if it is correct and if not, tell them sorry, please try again. If their answer...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TuitionIncrease. The college charges a full-time student $12,000 in tuition per semester. It has been announced that there will be a tuition increase by 5% each year for the next 7 years. Your application should display the projected semester tuition amount for the next 7 years in the console window in the following format:             The tuition after year 1 will be $12,600. Note:...
Create a C# console application (do not create a .NET CORE project) and name the project...
Create a C# console application (do not create a .NET CORE project) and name the project TimeToBurn. Running on a particular treadmill, you burn 3.9 calories per minute. Ask the user how many calories they wish to burn in this workout session (this is their goal). Once they tell you, output on the console after each minute, how many calories they have burned (e.g. After 1 minute, you have burned 3.9 calories). Keep outputting the total amount of calories they...
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...
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...
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...
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...
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...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in...
Create a new Visual Studio console project named assignment042, and translate the algorithm you developed in Assignment 04.1 to C++ code inside the main() function. Your program should prompt for a single 9-digit routing number without spaces between digits as follows: Enter a 9-digit routing number without any spaces: The program should output one of: Routing number is valid Routing number is invalid A C++ loop and integer array could be used to extract the routing number's 9 digits. However...
Create a Visual Studio console project named exercise101. The main() function should prompt for the name...
Create a Visual Studio console project named exercise101. The main() function should prompt for the name of a text file located in the same directory as exercise101.cpp, and search for a word in the text file as follows: Enter text file name: Enter search word: The program should print the number of occurrences of the word in the file: occurrences of were found in If the file could not be opened then display: File not found Use Stream file I/O...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT