Need a project done?

C++ Programming Developer

Search This Blog

C++: Suppose you are organizing a pizza and will give every person who attends exactly 3 slices of pizza. write program that accepts a number of people and then computes the minimum number of pizzas that you must order assuming there are 8 slices per pizza. Your program then outputs the number of pizzas needed and the number of slices that will be left over.

/*
C++ program:
Suppose you are organizing a pizza and will give every person who attends exactly 3 slices of pizza. write program that accepts a number of people and then computes the minimum number of pizzas that you must order assuming there are 8 slices per pizza. Your program then outputs the number of pizzas needed and the number of slices that will be left over.
*/

Output

Solution:

int main()
{
cout << "Peoples in the Party: "; int people; cin >> people;
int Pizzas_required = ceil(people * 3.0/8.0);
cout << Pizzas_required << " Pizzas required." << endl; // 1 person will eat 3/8th Pizza.
cout << Pizzas_required*8 - people*3 << " pieces left." << endl;
return 0;
}



No comments:

Post a Comment

"Don't let anyone ever make you feel like you don't deserve what you want."