Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you please write the code in C++ 1. With one cut across the middle of a pizz

ID: 3786216 • Letter: C

Question

Can you please write the code in C++

1. With one cut across the middle of a pizza you can cut off half, that is, 50% of the pizza. With one cut at a different place you can cut off

less than 50%. The length of the cut is called the "chord" and the piece

removed is called the "segment."

Look up (or derive yourself) the formula for the area of a segment in terms of the chord length and the diameter, and write a C++ program to ask for the chord

length in inches and print out the percentage of a 14" pizza remaining after the segment is cut off. Running your program should look like this:

Pizza diameter is 14".

Enter chord length in inches: 0

That cut leaves 100% of the pizza.

Enter chord length in inches: 14

That cut leaves 50% of the pizza.

Enter chord length in inches: 10.17

That cut leaves 90% of the pizza.

Use while(cin >> chord) so the program will keep reading and calculating until

end of file. Reminder: If you did not derive the formula yourself, state in a comment where you got the formula.

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
double diameter = 14, length;
cout << "Pizza diameter is " << diameter << " inches.";

cout << "Enter length length in inches: ";

while(cin >> length)
{
if(length==0){
    cout<<"That cut leaves 100% of the pizza"<<endl;
       }

int area = length*diameter/2;
       float percentage=(area*length)/100;
cout << " That cuts out " << percentage << " percent of the pizza. "<<endl;
cout << "Enter length length in inches: ";


}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote