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

(This needs to be done in C++) Your lease is up and it’s time to move. Unfortuna

ID: 3682200 • Letter: #

Question

(This needs to be done in C++) Your lease is up and it’s time to move. Unfortunately, you have a lot of stuff and you don’t want to spend too much time moving it because you’d rather be practicing your programming skills. Thankfully, you have friends who can help, though this help comes at a cost. Your friends can move 20 boxes an hour, but they require one 16 inch (diameter) pizza for this work. Write a function in C++ that takes the number of boxes you have and returns how much square feet of pizza you will have to buy. Use the function header: sqFtPizza(int numBoxes) and have it return the square feet of pizza as a float. Assume that the pizzas are perfectly round and that your friends require a full pizza even if they only work a partial hour. (In case you’ve forgotten your geometry, the area of a circle is pi*r^2. Use 3.14159 for pi.)

Explanation / Answer

#include<iostream>
using namespace std;

#define pi 3.14159
#define rad 8 //as diameter is 16 inches

const int hr=20;
long double sqFtPizza(int numBoxes);

int main()
{
int n;  
cout<<" Enter the number of boxes : ";
cin>>n;
long double pz = sqFtPizza(n);
cout<<" You need to buy "<<pz<<" sq ft. of pizza";
}
/* The required function that first calculates how many pizzas are required as stores as count.
   Even if the number of boxes is 1 more than a multiple of 20, an extra pizza is considered to be
   bought. Then area for one pizza is multiplied by count to give area of count pizzas in sqr inches.
   Finally it is converted to sqr ft. by dividing it by 144*/
long double sqFtPizza(int numBoxes)
{
int count; //total no. of pizzas required
long double area;
if(numBoxes%hr!=0)
   count = numBoxes/hr + 1;
else
   count = numBoxes/hr;

area = count*pi*rad*rad; //area of pizza required in square inches
area = area/144; //area of pizza required in square ft.
return area;
}