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 6716913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:47:24+00:00 2026-05-26T08:47:24+00:00

Hi i am studing to be a programmer and this is a project i

  • 0

Hi i am studing to be a programmer and this is a project i am working on. The console basically takes the users input (diameter) and tells you how many pizza slices you will get and the area of each slice. after telling them the slices and area of each, it must promt for new input. Slices are determined based on ranges such as 12 – 20″ of diameter = 8 slices. a user has to enter in a range between 12″ – 36″ or they get an error message. Also if the user enters in a diameter of 36, it must show all of the other slices in decrements of 4, so 24 , 20, 16 ,12 , 8 . but if the diameter ends up falling under the 8 slices, it must only show that. hence 12 slices will show 8 slices and 12 slices.

lastly, we are learning about loops, we are to use the do while loop, and the for loop in this project.

this is what i have, and it doesnt work.

        //DECLARATIONS
        double circleArea;  // area of pizza
        double diameter; // diameter of the pizza
        double areaOfSlice; // area of the slices
        double radius; // half the diameter of the pizza
        double slices = 0; // number of pizza slices
        string message = ""; // a string to hold a message to the user
        const int DIAMETER_RANGE_MASSIVE = 36;
        const int DIAMETER_RANGE_EXTRA_LARGE = 30;
        const int DIAMETER_RANGE_LARGE = 24;
        const int DIAMETER_RANGE_MED = 16;
        const int DIAMETER_RANGE_LOW = 12; // Low end on range scale for diameter
        const int SLICES_LOW_DIAMETER = 8; // number of pizza slices based on diameter
        const int SLICES_MID_DIAMETER = 12; // number of pizza slices based on diameter
        const int SLICES_HIGH_DIAMETER = 16; // number of pizza slices based on diameter
        const int SLICES_GIANT_DIAMETER = 24; // number of pizza slices based on diameter        
        bool needInput = true;
        const int END_PROGRAM = 0;




        // INPUT
        // Prompt for and get keyboard input

        Console.Write("Please enter the diameter of your pizza (0 to end program): ");  // get user to input diameter
        diameter = Convert.ToDouble(Console.ReadLine()); // read a line of text (string) from the keyboard,
        // convert that string to an double,
        // assign the resulting value to diameter

        // PROCESSING
        // determine if diameter meets requirements of 12" to 36"
        // if does not meet requirements show error message and have user enter in new diameter
        do
        {
            if (diameter < DIAMETER_RANGE_LOW || diameter > DIAMETER_RANGE_MASSIVE)

            {
                message = "\nENTRY ERROR";
                message += "\nPizza must have a diameter in the range of 12” to 36” inclusive!";
                message += "\nPlease try again.";
            }



        else {    
            needInput = false;
                // determine the number of slices based on diameter


                if (diameter >= DIAMETER_RANGE_LOW && diameter < DIAMETER_RANGE_MED)
                {
                    slices = (SLICES_LOW_DIAMETER);
                }
                else if (diameter < DIAMETER_RANGE_LARGE)
                {
                    slices = (SLICES_MID_DIAMETER);
                }
                else if (diameter < DIAMETER_RANGE_EXTRA_LARGE)
                {
                    slices = (SLICES_HIGH_DIAMETER);
                }
                else
                {
                    slices = (SLICES_GIANT_DIAMETER);
                }

                Console.Clear(); // clears console to show new output lines
                //OUTPUT
                for (int slicesAddFour = 8; slicesAddFour <=slices; slicesAddFour+=4) // for each slices
                {
                // determine the area of the slices
                radius = diameter / 2; // uses diameter to get radius
                circleArea = Math.PI * Math.Pow(radius, 2); // uses math class to calculate circle area  
                areaOfSlice = Math.Round((circleArea / slices), 2); // divides circle area by slices, takes the result of above calculation and rounds

                Console.WriteLine("\nA {0}\" Pizza diameter: {0}\".", diameter); 
                message +=("\n==============================================");
                Console.WriteLine("\nCut in {0} slices results in an area of {1}\" per slice.",areaOfSlice,slices);

                }


        } //end of else

            message = ("\nPlease enter the diameter of your pizza (0 to end program)");
            needInput = true;
        } while (diameter != END_PROGRAM && needInput);
    }
}

}

  • 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-05-26T08:47:24+00:00Added an answer on May 26, 2026 at 8:47 am
    using System;
    
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace Lab6B
    {
        class Program
        {
            static void Main(string[] args)
            {
                //DECLARATIONS
                double circleArea;  // area of pizza
                double diameter; // diameter of the pizza
                double areaOfSlice; // area of the slices
                double radius; // half the diameter of the pizza
                double slices = 0; // number of pizza slices
                const int INPUT_MAX = 36; // maximum entry for diameter
                const int DIAMETER_RANGE_EXTRA_LARGE = 30; // diameter range used to figure out slices
                const int DIAMETER_RANGE_LARGE = 24; // diameter range used to figure out slices
                const int DIAMETER_RANGE_MED = 16; // diameter range used to figure out slices
                const int INPUT_MIN = 12; // minimum entry for diameter
                const int SLICES_LOW_DIAMETER = 8; // number of pizza slices based on diameter
                const int SLICES_MID_DIAMETER = 12; // number of pizza slices based on diameter
                const int SLICES_HIGH_DIAMETER = 16; // number of pizza slices based on diameter
                const int SLICES_GIANT_DIAMETER = 24; // number of pizza slices based on diameter        
                bool needInput = true; // does the program need input true or false
                const int END_PROGRAM = 0; // 0 ends the program
    
    
    
    
    
                // INPUT
                // Prompt for and get keyboard input
    
                Console.Write("Please enter the diameter of your pizza: ");  // get user to input diameter
                diameter = Convert.ToDouble(Console.ReadLine()); // read a line of text (string) from the keyboard, 
    
                // convert that string to an double,
                // assign the resulting value to diameter
    
                while (diameter != END_PROGRAM && needInput) // Begin while loop
    
                {
    
                    // PROCESSING
    
                    // determine if diameter meets requirements of 12" to 36"
                    // if does not meet requirements show error message and have user enter in new diameter
    
    
                    if (diameter < INPUT_MIN || diameter > INPUT_MAX)
                    {
    
                        Console.WriteLine( "\nENTRY ERROR\nPizza must have a diameter in the range of 12” to 36” inclusive!\nPlease try again.");
                    }
    
    
                    else
                    {
                        needInput = false;
                        // determine the number of slices based on diameter
    
    
                        if (diameter < DIAMETER_RANGE_MED)
                        {
                            slices = (SLICES_LOW_DIAMETER);
                        }
                        else if (diameter < DIAMETER_RANGE_LARGE)
                        {
                            slices = (SLICES_MID_DIAMETER);
                        }
                        else if (diameter < DIAMETER_RANGE_EXTRA_LARGE)
                        {
                            slices = (SLICES_HIGH_DIAMETER);
                        }
                        else
                        {
                            slices = (SLICES_GIANT_DIAMETER);
                        }
    
                        Console.Clear(); // clears console to show new output lines
    
                        //OUTPUT
    
                        Console.WriteLine("\nA {0}\" Pizza diameter: {0}\".", diameter);
                        Console.WriteLine("\n==============================================");
    
                        for (int slicesAddFour = 8; slicesAddFour <= slices; slicesAddFour += 4) // for each slices
                        {
                            // determine the area of the slices
                            radius = diameter / 2; // uses diameter to get radius
                            circleArea = Math.PI * Math.Pow(radius, 2); // uses math class to calculate circle area  
                            areaOfSlice = Math.Round((circleArea / slicesAddFour), 2); // divides circle area by slices, takes the result of above calculation and rounds
    
    
                            Console.WriteLine("\nCut in {0} slices results in an area of {1}\" per slice.", slicesAddFour, areaOfSlice);
    
    
                        }
    
    
                    } //end of else
    
                    Console.Write("\nPlease enter the diameter of your pizza (0 to exit): ");
                    diameter = Convert.ToDouble(Console.ReadLine());
                    Console.Clear(); // clears console to show new output lines
    
                    // set the need input value back to true for new entry
                    needInput = true;
    
                 } // end of while loop
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a J2SE programmer from 3 years, and I would like to start studing
I'm studing on a project. It's a bank simulation and just for practicing OOP
I am studying the content of Programming Ruby- The Pragmatic Programmer's Guide but the
I'm studing C++ and I can't understand the meaning of the boldface sentence below:
I'm PHP-programmer, but I'm extremely interested in learning Java. So I decided to change
I'm studying for Java Programmer Certification (SCJP) exam. A question about exceptions, when handle
I'm reading The Pragmatic Programmer and I'm on the section where the authors suggest
Studing STL I have written a a simple program to test functors and modifiers.
I am newer studing php. I have asked my question in php facebook people
A friend from college is studing web programming using the tapestry framework, and he

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.