Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8849849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:45:39+00:00 2026-06-14T12:45:39+00:00

Hi all I have been having some problems with a task I have been

  • 0

Hi all I have been having some problems with a task I have been set

The first part of the task was to output a price table with the following rules:

The price for up to 50 is £5 each. For between 51 and 80, the price is £4 each, while for between 81 and 100 the price is a rock bottom £2.50 each.
Using loop structures and selection statements (if.. etc) your program should output a widget price chart for widgets in multiples of 10 up to 100.

I have done this however the second part of the task has me stumped
after the table has been output to input a number of widgets. You should then calculate the cost and output the value. If the user enters ‘q’ or ‘Q’, the program should terminate.

Here is the full code

using System;
namespace w5Task3
{
class Program
    { public static void Main ( string[] args )
            {

            double PriceEach1 = 5;
            double PriceEach2 = 4;
            double PriceEach3 = 2.50;
            double Quantity = 10;
            int UserOrder=0;

            Console.WriteLine("\n\nBelow is the price chart:\n\n");
            Console.WriteLine("WidgetQuantity\t\t\tPrice\n");
            while (Quantity <=100)

                {   

                    double Price1 = PriceEach1*Quantity;
                    double Price2 = PriceEach2*Quantity;
                    double Price3 = PriceEach3*Quantity;


                        if (Quantity <=50)      
                    {
                        Console.WriteLine("\t{0}\t\t\t{1:C}", Quantity, Price1);
                    }


                        if(Quantity >=51 && Quantity <=80)      
                    {
                        Console.WriteLine("\t{0}\t\t\t{1:C}", Quantity, Price2);
                    }


                        if (Quantity >80 && Quantity <=100)
                    {
                        Console.WriteLine ("\t{0}\t\t\t{1:C}",Quantity, Price3);                        
                    }
                Quantity +=10;
                }


            while (UserOrder >=0)
                {
                    try
                        {
                        Console.WriteLine("Enter the amount of widgets you would like to purchase or press q to quit");
                        string temp = Console.ReadLine();
                        if (temp =="q") break;
                        if (temp =="Q") break;

                        int.TryParse(temp, out UserOrder);

                        double UserPrice;

                        if (UserOrder <=50)
                            {
                                UserPrice = UserOrder*5;
                                Console.WriteLine("The price is {0:C}",UserPrice);
                            }

                        if (UserOrder >=51 && UserOrder <=80)
                            {
                                UserPrice = UserOrder*4;
                                Console.WriteLine("The price is {0:C}",UserPrice");
                            }

                        if (UserOrder >80)
                            {
                                UserPrice = UserOrder*2.5;
                                Console.WriteLine("The price is {0:C}",UserPrice");
                            }


                        }
                            catch(Exception)
                                {
                                    Console.WriteLine("You have entered an incorrect value. Please enter a number or press q to quit");
                                }
                }



            }
    }

The part I am having issues with is:

                while (UserOrder >=0)
                {
                    try
                        {
                        Console.WriteLine("Enter the amount of widgets you would like to purchase or press q to quit");
                        string temp = Console.ReadLine();
                        if (temp =="q") break;
                        if (temp =="Q") break;

                        int.TryParse(temp, out UserOrder);

                        double UserPrice;

                        if (UserOrder <=50)
                            {
                                UserPrice = UserOrder*5;
                                Console.WriteLine("The price is {0:C}",UserPrice);
                            }

                        if (UserOrder >=51 && UserOrder <=80)
                            {
                                UserPrice = UserOrder*4;
                                Console.WriteLine("The price is {0:C}",UserPrice");
                            }

                        if (UserOrder >80)
                            {
                                UserPrice = UserOrder*2.5;
                                Console.WriteLine("The price is {0:C}",UserPrice");
                            }


                        }
                            catch(Exception)
                                {
                                    Console.WriteLine("You have entered an incorrect value. Please enter a number or press q to quit");
                                }
                }
}

I can get the program to quit or do one UserPrice but it is when I need to make it change the price dependent on the amount ordered.

Any help or suggestions are much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:45:40+00:00Added an answer on June 14, 2026 at 12:45 pm

    You have newlines in your constant expressions at lines 67 and 73!

    Fix those, and it all runs fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been having some problems with the test debugger in VS10. All tests
Hi, i have been having some problems using JSON data in flash builder lately
I've been having some problems with using BerkeleyDB. I have multiple instances of the
Good day everyone. I have been having the same problem all day at work
i am haveing some problems with JSON and arrays. I have been messing around
I've recently been having some problems with my imports in Django (Python)... It's better
I've been having some problems with a few Fan Pages and getting their details
I am having some problems creating custom types for my data table, using jquery.datatables.js.
I've been playing around with some linq to xml, and I'm having some problems
I have been having problems installing programs for a while, Usually getting an error

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.