Maha

Maha

  • NA
  • 0
  • 326.5k

What’s wrong with this program?

Aug 8 2012 10:00 AM
This is question 4th of the exercise. Whatever wood variety is chosen, output price of the wood is first chosen variety is coming. Please fix the error.

using System;

namespace _5e4
{
class Furniture
{
static void Main(string[] args)
{
string choose, replay;

Console.Write("[P for pine] [O for oak] [M for mahogany] Choose varity: ");

choose = Console.ReadLine();

while (choose == "P" || choose == "O" || choose == "M")
{
if (choose == "P")
Console.WriteLine("\t\t\t\t\t\t\tPine Price $100");

if (choose == "O")
Console.WriteLine("\t\t\t\t\t\t\tOak Price = $225");

if (choose == "M")
Console.WriteLine("\t\t\t\t\t\t\tMahogany Price = $310");

replay = Choose();
}

Console.ReadKey();
}
public static string Choose()
{
Console.Write("\n[P for pine] [O for oak] [M for mahogany] Choose varity: ");
string choose = Console.ReadLine();
return choose;

}
}
}
/*
[P for pine] [O for oak] [M for mahogany] Choose varity: P
Pine Price $100

[P for pine] [O for oak] [M for mahogany] Choose varity: O
Pine Price $100

[P for pine] [O for oak] [M for mahogany] Choose varity: M
Pine Price $100
*/

Answers (4)