You were nearly there, I have made your loop use the index E.g {i+1}
Console.WriteLine($"{i+1}. {name[i]} ${price[i]} per night")
The result to use the token {nights} and the calculation to be {price[room-1] * nights}
Example
string[] name = { "Single", "Double", "Luxury", "Penthouse" };
double[] price = { 45.50, 99.99, 165.25, 1095.50 };
Console.WriteLine("Room Types");
for (int i = 0; i < name.Length; i++)
Console.WriteLine($"{i+1}. {name[i]} ${price[i]} per night");
Console.Write("\nPlease select a room type 1, 2, 3 or 4: ");
var room = int.Parse(Console.ReadLine());
Console.Write("Please enter the number of nights: ");
var nights = int.Parse(Console.ReadLine());
Console.WriteLine($"\nThank you, the total cost for staying in the ? room for 5 nights is {price[room-1] * nights}");
Console.ReadLine();
Output
Room Types
1. Single $45.5 per night
2. Double $99.99 per night
3. Luxury $165.25 per night
4. Penthouse $1095.5 per night
Please select a room type 1, 2, 3 or 4: 2
Please enter the number of nights: 2
Thank you, the total cost for staying in the ? room for {nights} nights is 199.98
Also note, never use parse type methods for user input, use TryParse type methods to protect against pesky users who can't read instructions.
A more modern approach
internal class Program
{
public record Room(string Name, double Price);
public static Room[] _rooms =
{
new("Single", 45.50),
new("Double", 99.99),
new("Luxury", 165.25),
new("Penthouse", 1095.50 ),
};
private static void Main(string[] args)
{
do
{
Console.WriteLine("Room Types");
for (int i = 0; i < _rooms.Length; i++)
Console.WriteLine($"{i + 1}. {_rooms[i].Name} ${_rooms[i].Price} per night");
Console.Write($"\nPlease select a room type between 1 and {_rooms.Length} : ");
int room;
while (!int.TryParse(Console.ReadLine(), out room) || room <= 0 || room > _rooms.Length)
Console.Write("Omg, you had one job, follow the instructions : ");
Console.Write("Please enter the number of nights : ");
int nights;
while (!int.TryParse(Console.ReadLine(), out nights))
Console.Write("Omg, you had one job, follow the instructions : ");
Console.WriteLine($"\nThank you, the total cost for staying in the ? room for {nights} nights is {_rooms[room - 1].Price * nights}");
Console.WriteLine("Game over... press any key to play again, or enter to exit");
} while (Console.ReadLine() == null);
Console.WriteLine("be gone...");
}
}
Output
Room Types
1. Single $45.5 per night
2. Double $99.99 per night
3. Luxury $165.25 per night
4. Penthouse $1095.5 per night
Please select a room type between 1 and 4 : fgdsfgdsfg
Omg, you had one job, follow the instructions : 2
Please enter the number of nights : 2
Thank you, the total cost for staying in the ? room for 2 nights is 199.98
Game over... press any key to play again, or enter to exit
be gone...
price[room] * nights? orprice[room-1] * nightsdepending