Consider the following scenario: A landscape service has hired you to create a n
ID: 3798233 • Letter: C
Question
Consider the following scenario: A landscape service has hired you to create a new tracking system. They have 2 types of appointments: morning and afternoon. There are 5 appointments for morning and 5 for afternoon. Using an array, create a C# application that prompts the user for the appointment type (morning or afternoon) then reserves a slot of that type. The first 5 array slots are morning and the second 5 slots are afternoon. If there is no appointment of that type available, show a message telling the user that there is no appointment available. Your screenshot must show the appointment type request and the slot assigned. Your application must test using the test cases shown below. Run all of the test cases in one execution of your application. Include the test prompts in your screenshot At the beginning of your program, display your name and the assignment due date Test cases: Afternoon Morning Afternoon Afternoon Afternoon Afternoon. Afternoon MorningExplanation / Answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication7
{
class Program
{
static void Main(string[] args)
{
String name;
String date;
Console.WriteLine("enter your name");
name = Console.ReadLine();
Console.WriteLine("enter the assignment due date");
date = Console.ReadLine();
String[] array = new String[10];
for(int i=0;i<10;i++)
{
if(i<5)
{
array[i] = "morning";
}
else
{
array[i] = "afternoon";
}
}
Console.WriteLine("the available slots are ");
for(int i=0;i<10;i++)
{
Console.WriteLine("{0}", array[i]);
}
int morningcount = 0;
int afternooncount = 0;
for (int i = 0; i < 20; i++)
{
if(morningcount>5&&afternooncount >5)
{
Console.WriteLine("there is no slots are available all are registered thanks for visiting");
Environment.Exit(0);
}
Console.WriteLine("do you want register the appointments if type y/n");
String confirmation = Console.ReadLine();
if (confirmation.Trim().Equals("y"))
{
Console.WriteLine("enter your appointment type");
String appointmentType = Console.ReadLine();
if (appointmentType.Trim().Equals("morning") || appointmentType.Trim().Equals("afternoon"))
{
if (appointmentType.Trim().Equals("morning"))
{
++morningcount;
if (morningcount <= 5)
{
Console.WriteLine("your requested appointment slot is granted");
Console.WriteLine("your slot no in the morning is :{0}", morningcount);
}
else
Console.WriteLine("no slots are available in the morning please try with another type of slots");
}
if (appointmentType.Trim().Equals("afternoon"))
{
++afternooncount;
if (afternooncount <= 5)
{
Console.WriteLine("your requested appointment slot is granted");
Console.WriteLine("your slot no in the afternoon is :{0}", afternooncount);
}
else
Console.WriteLine("no slots are available in the afternoon please try with another type of slots");
}
}
else
Console.WriteLine("no such type of appointment are not available");
}
else
{
Console.WriteLine("thanks for booking the slots");
Environment.Exit(0);
}
}
Console.WriteLine("you booked all the slots thank you ");
Console.ReadKey();
}
}
}
output
enter your name
david
enter the assignment due date
28/02/2017
the available slots are
morning
morning
morning
morning
morning
afternoon
afternoon
afternoon
afternoon
afternoon
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
your requested appointment slot is granted
your slot no in the afternoon is :1
do you want register the appointments if type y/n
y
enter your appointment type
morning
your requested appointment slot is granted
your slot no in the morning is :1
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
your requested appointment slot is granted
your slot no in the afternoon is :2
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
your requested appointment slot is granted
your slot no in the afternoon is :3
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
your requested appointment slot is granted
your slot no in the afternoon is :4
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
your requested appointment slot is granted
your slot no in the afternoon is :5
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
no slots are available in the afternoon please try with another type of slots
do you want register the appointments if type y/n
y
enter your appointment type
morning
your requested appointment slot is granted
your slot no in the morning is :2
do you want register the appointments if type y/n
y
enter your appointment type
afternoon
no slots are available in the afternoon please try with another type of slots
do you want register the appointments if type y/n
n