Question #59720

Write a main() that creates a hotel room with room number 123, with a capacity of 4, and a rate of 150.00. Suppose a person checks in. The program should ask the user to enter the number of guests to occupy the room. Change the status of the room to reflect the number of guests that just checked in. Display the information about the room in a nicely formatted way. Now assume that the guests check out. Change the status of the room appropriately and display the information about the room. Next, change the room rate to 175.00. Finally, assume that another person checks in. Ask the user to enter the number of guests to occupy the room. Change the room’s status accordingly and display the new information about the room.
1

Expert's answer

2016-05-08T10:40:02-0400

Answer on Question #59720 - Programming & Computer Science - C# | Completed

Task:

Write a main() that creates a hotel room with room number 123, with a capacity of 4, and a rate of 150.00. Suppose a person checks in. The program should ask the user to enter the number of guests to occupy the room. Change the status of the room to reflect the number of guests that just checked in. Display the information about the room in a nicely formatted way. Now assume that the guests check out. Change the status of the room appropriately and display the information about the room. Next, change the room rate to 175.00. Finally, assume that another person checks in. Ask the user to enter the number of guests to occupy the room. Change the room's status accordingly and display the new information about the room.

Answer:


using System;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Room
{
public Room()
{
Number = 123;
Capacity = 4;
Rate = 150;
Checked = false;
}
public int Number { get; set; }
public int Capacity { get; set; }
public double Rate { get; set; }
public Boolean Checked { get; set; }
public override string ToString()
{
String s = "";
s = Checked ? "checked." : "unchecked.";
return "Number of the room : " + Number.ToString() + ", capacity : " + Capacity.ToString() + ", rate : " + Rate.ToString() + ", room is " + s;
}
}
class Program
{
static void Main(string[] args)
{
Room room = new Room();
}
int num_of_guests;
Console.Write("Enter number of guests: ");
num_of_guests = Convert.ToInt32(Console.ReadLine());
room.Capacity = num_of_guests;
room.Checked = true;
Console.WriteLine(room.ToString());
room.Checked = false;
room.Rate = 175.00;
Console.Write("Enter number of guests: ");
num_of_guests = Convert.ToInt32(Console.ReadLine());
room.Capacity = num_of_guests;
room.Checked = true;
Console.WriteLine(room.ToString());
Console.Read();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS