Write a C# console application for a furniture company. Ask the user to choose P
ID: 3866425 • Letter: W
Question
Write a C# console application for a furniture company. Ask the user to choose P for pine, O for oak, and M for mahogany. Show the price of a table manufactured with the chosen wood. Pine tables cost $100, oak tables cost $225, and mahogany tables cost $310. If the user enters something other than P, O or M, set the price to $0. Save your program as Furniture.cs.
emphasis on the C# program.
this is what i have but it keeps giving me an error saying "Method must have return type" on line 6. Please help.
using System;
namespace Furniture {
class Furniture {
static voidMain(string[] args){
//define specification
string option = "";
Console.WriteLine("Please choose an option for selecting table :");
//ask user for wood specification
Console.WriteLine("P for Pine");
Console.WriteLine("O for Oak");
Console.WriteLine("M for Mahogany");
//read string
option = "" + Console.ReadLine();
switch (option)
{
//if user inputs P
case "P":
case "p":
Console.WriteLine("Pine table costs $100");
break;
//if user inputs O
case "O":
case "o":
Console.WriteLine("Oak table costs $225");
break;
//if user inputs M
case "M":
case "m":
Console.WriteLine("Mahogany table costs $310");
break;
//invalid input
default:
Console.WriteLine("Invalid Table option... Price is $0");
break;
}
//print out result
Console.ReadLine();
}
}
}
Explanation / Answer
The changes have been made
using System;
namespace Furniture {
class Furniture {
public static void Main(string[] args){
//define specification
string option = "";
Console.WriteLine("Please choose an option for selecting table :");
//ask user for wood specification
Console.WriteLine("P for Pine");
Console.WriteLine("O for Oak");
Console.WriteLine("M for Mahogany");
//read string
option = "" + Console.ReadLine();
switch (option)
{
//if user inputs P
case "P":
case "p":
Console.WriteLine("Pine table costs $100");
break;
//if user inputs O
case "O":
case "o":
Console.WriteLine("Oak table costs $225");
break;
//if user inputs M
case "M":
case "m":
Console.WriteLine("Mahogany table costs $310");
break;
//invalid input
default:
Console.WriteLine("Invalid Table option... Price is $0");
break;
}
//print out result
Console.ReadLine();
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.