Answer to Question #243806 in C# for mack

Question #243806

Write an application for a furniture company; the program determines the price of a table. Ask

the user to choose one for pine, 2 for oak, or three for mahogany. The output is the name of the

wood chosen as well as the price of the table. Pine tables cost $100, oak tables cost $225, and

mahogany tables cost $310. If the user enters an invalid wood code, set the price to zero. Save

the file as Furniture.cs


1
Expert's answer
2021-09-29T11:29:07-0400
using System;


namespace Questions
{
    class Program
    {
        static decimal DeterminePriceOfTable(int wood)
        {
            if (wood == 1)
                return 100;
            if (wood == 2)
                return 225;
            if (wood == 3)
                return 310;
            return 0;
        }
        static void Main()
        {
            Console.WriteLine("Please select a wood:");
            Console.WriteLine("1. Pine");
            Console.WriteLine("2. Oak");
            Console.WriteLine("3. Mahogany");


            Console.WriteLine();
            Console.Write("Your choice: ");
            int choice = int.Parse(Console.ReadLine());
            Console.WriteLine();


           


            if(choice >= 1 && choice <= 3)
            {
                if (choice == 1)
                    Console.WriteLine("Wood: Pine");
                else if (choice == 2)
                    Console.WriteLine("Wood: Oak");
                else if (choice == 3)
                    Console.WriteLine("Wood: Mahogany");


            }
            else
                Console.WriteLine("Invalid wood code");


            decimal tablePrice = DeterminePriceOfTable(choice);
            Console.WriteLine("Price of the table: $" + tablePrice);




            Console.ReadKey();
        }
    }
}

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!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS