C# console application

cowgirl1996cowgirl1996 United States

I'm extremely new to C# and having a very hard time with this one. Any and all help is greatly appreciated! The more detailed the help the better because I'm pretty lost on this one.

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.

Comments

  • cowgirl1996cowgirl1996 United States

    This is what I have so far:
    using namespace furniture;

    int main()
    {
    int a,b,c;
    double r;
    char ch,o,m,p;

    c=0;

    cout<< "Enter your spending limit."<<endl;
    cin>>b;
    cout<< "Please choose between Pine, Oak, Mahoganhi."<<endl;
    cin>>ch;

    switch(ch)
    {

    case 'p':

    a = 100;
    do
    {
    r=c+a;
    cout<<r<<endl;
    c=r;
    }
    while(r!=b);
    break;

    case 'o':
    a=225;

    do
    {
    r=c+a;
    cout<<r<<endl;
    c=r;
    }
    while(r!=b);
    break;

    case 'm':

    a=350;
    do
    {
    r=c+a;
    cout<<r<<endl;
    c=r;
    }
    while(r!=b);
    break;
    }

    return 0;
    }
    }
    }

  • mazanujmazanuj Ukraine, Kiev

    Something like this (if understand you correctly)

    using System;
    namespace Help
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.Write("Enter your spending limit: ");
                int b = Convert.ToInt32(Console.ReadLine());
                Console.Write("Please choose between Pine(p), Oak(o), Mahoganhi(m): ");
                string ch = Console.ReadLine();
                switch(ch)
                {
                    case "p":
                        Console.WriteLine("Number of tables (Pine): {0}", b % 100);
                        break;
                    case "o":
                        Console.WriteLine("Number of tables (Oak): {0}", b % 225);
                        break;
                    case "m":
                        Console.WriteLine("Number of tables (Mahoganhi): {0}", b % 310);
                        break;
                    default:
                        Console.WriteLine("Incorrect input");
                        break;
                }
                //Delay
                Console.ReadKey();
            }
        }
    }
  • cowgirl1996cowgirl1996 United States

    Yes something very similar, but all I need to do is have them pick a type of wood and display the price for that wood.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories