Your lease is up and it’s time to move. Unfortunately, you have a lot of stuff a
ID: 3682415 • Letter: Y
Question
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
Here It is asking the case of number of boxes is 20 or less from the statement that tells your friends require a full pizza even if they only work a partial hour.
if number of boxes is less obviously the time to work aslo reduced.therefore the following code does the same.
code:
#include <iostream>
#define pi 3.14159
using namespace std;
float sqFtPizza(int numBoxes)
{
if(numBoxes > 0 && numBoxes <= 20)
{
return pi*8*8;
}
}
int main()
{
int numOFBoxes=0;
cout << "Enter the Number of Boxes :" ;
cin >> numOFBoxes;
cout <<sqFtPizza(numOFBoxes) << " square feet of pizza you will have to buy "<<endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.