General discussion

  • Creator
    Topic
  • #2277027

    c sharp

    Locked

    by overload ·

    This should be a simple problem. I’m working in console only and its a carpet calculator. I have the calculations for the carpet prices complete. I need to add in styles in a switch case. Like Console.Write(“(1) Berber (2) Plush”) all the way up to six different styles.

    On the console you would type #1 and it will repeat the desired selection and price quote. If by accident you typed an A or a #9 then it would state on the console “You have selected the wrong number” Now if the number entered is right then it will start the calculations.

    From what I understand I need a “switch and case statement”. “I need a bool, I need a If else and a do while statement.” in addition to my calculations. This is in c #.

All Comments

  • Author
    Replies
    • #3296948

      Reply To: c sharp

      by asjwm2 ·

      In reply to c sharp

      OK,
      int carpetType;
      double berberPricePerYard = 5.00;
      double shagPricePerYard = 6.00;
      double cost, yards;
      // Shag it Austin Powers !!
      switch(carpetType)
      {
      case 1 : cost = berberPricePerYard * yards;
      case 2 : cost = shagPricePerYard * yards;
      default : break;
      }
      Before this, you have something like :
      do
      {
      cout << "Enter carpet type (1-4):" cin >> carpetType;
      }
      while((carpetType < 1) || (carpettype > 4));

      So what you do is :
      1) make sure the input is good
      2) “cost” is now the correct cost for carpetType
      Before this, you want to have a “menu” routine. Reading integers is much easier than reading character strings, so the output is :

      For shag, enter 1
      For Dupont Antron, enter 2
      For stain free Rayon, enter 3
      For Tibetan yak weave, enter 4

      otherwise, you would have to account for :
      Don’s special 3 inch Orlon yarn
      or some such…

      So it goes :
      1) menu for what kind of carpet
      2) how many yards ?
      3) And the cost for wall-to-wall is ??%(^&%*&
      Johnny

    • #3296057

      Reply To: c sharp

      by overload ·

      In reply to c sharp

      I’m sorry your answer is a bit over my head. I copied and pasted it to the board, but limited to 2000 characters here. I could zip the file in XP and send it to you in complete and understandable format. Please let me know.
      knowledgeispower@tds.net
      Thanks very much for answering.
      Richard

Viewing 1 reply thread