Question

(The file should have your program and the console input/output of your program) 3.18: Pizza Pi...

(The file should have your program and the console input/output of your program)

3.18: Pizza Pi

Joe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. The program should perform the following steps:

Ask the user for the diameter of the pizza in inches.

Calculate the number of slices that may be taken from a pizza of that size.

Display a message telling the number of slices.

To calculate the number of slices that may be taken from the pizza, you must know the following facts:

Each slice should have an area of 14.125 inches.

To calculate the number of slices, simply divide the area of the pizza by 14.125.

The area of the pizza is calculated with this formula: Area = "pi r squared" where pi is approximately 3.14159 and r is the radius (half the the diameter).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// C++ code
#include <iostream>
#include <fstream>
#include <cctype>
#include <cstring>
#include <stdlib.h> /* srand, rand */
#include <iomanip>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <string.h>

#define PI 3.14159
#define SLICE_AREA 14.125
using namespace std;

int main()
{

double radius_pizza;
double area_pizza;
double slice_perPizza;
double diameter;

cout << "Enter pizza diameter: ";
cin >> diameter;


radius_pizza = diameter / 2;
area_pizza = PI*radius_pizza*radius_pizza;
slice_perPizza = area_pizza / SLICE_AREA;

cout << int(slice_perPizza) << " slices" << endl;

return 0;
}

/*
output:

Enter pizza diameter: 10
5 slices

*/

Add a comment
Know the answer?
Add Answer to:
(The file should have your program and the console input/output of your program) 3.18: Pizza Pi...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Murphy Pizza Palace needs an application to calculate the number of slices of a pizzaof any...

    Murphy Pizza Palace needs an application to calculate the number of slices of a pizzaof any size can be divided into. The application should do the following: Allow the user to enter the diameter of the pizza, in inches. Calculate the number of slices that can be cut from a pizza that size. Display a message that indicates the number of slices. To calculate the number of slices that can be cut from the pizza, you must know the following...

  • A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices...

    A restaurant called Tony’s Pizza Palace needs a program to help calculate rhe number of slices a pizza of any aize can be divided into, and hoe many pizzas should be ordered for a party. The program will assume each person at the party will eat 3 slices of pizza each. The program should prompt the user for the diameter of the pizzas they wish to order. it will also ask the user for the number of people who will...

  • The program will need to accept two input arguments: the path of the input file and...

    The program will need to accept two input arguments: the path of the input file and the path of the output file. See etc/cpp/example.ifstream.cpp for the basis of how to do this. Once the input and output file paths have been received, the program will need to open the input and output files, read and process each input file line and create a corresponding output file line, close the input and output files, and then create and output some summary...

  • This assignment tests your ability to write C programs that handle keyboard input, formatted console output,...

    This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input/output with text files. The program also requires that you use ctype functions to deal with the logic. In this program, you will input from the user two characters, which should both be letters where the second letter > the first letter. You will then input a file character-by-character and output those letters that fall between the two characters (inclusively) to an output...

  • /*************************************************** Name: Date: Homework #7 Program name: HexUtilitySOLUTION Program description: Accepts hexadecimal numbers as input. Valid...

    /*************************************************** Name: Date: Homework #7 Program name: HexUtilitySOLUTION Program description: Accepts hexadecimal numbers as input. Valid input examples: F00D, 000a, 1010, FFFF, Goodbye, BYE Enter BYE (case insensitive) to exit the program. ****************************************************/ import java.util.Scanner; public class HexUtilitySOLUTION { public static void main(String[] args) { // Maximum length of input string final byte INPUT_LENGTH = 4; String userInput = ""; // Initialize to null string Scanner input = new Scanner(System.in); // Process the inputs until BYE is entered do {...

  • In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, t...

    In C++ Write a menu driven C++ program to read a file containing information for a list of Students, process the data, then present a menu to the user, and at the end print a final report shown below. You may(should) use the structures you developed for the previous assignment to make it easier to complete this assignment, but it is not required. Required Menu Operations are: Read Students’ data from a file to update the list (refer to sample...

  • Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

    Use program control statements in the following exercises: Question 1 . Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds. Question 2. The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured...

  • summarizr the followung info and write them in your own words and break them into different...

    summarizr the followung info and write them in your own words and break them into different key points.   6.5 Metering Chamber: 6.5.1 The minimum size of the metering box is governed by the metering area required to obtain a representative test area for the specimen (see 7.2) and for maintenance of reasonable test accuracy. For example, for specimens incorporating air spaces or stud spaces, the metering area shall span an integral number of spaces (see 5.5). The depth of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT