/*	~cs35/worker_count.cpp		9/25/01			Drawer 76
		To motivate the introduction of "while" loops
*/

#include <iostream.h>
#include <iomanip>

int main ( )
{
	int total
		int dormnumber
			int contribution
				int r
					int e;
	
	cout << "How many workers are needed? (99 max) ";
	cin  >> total;
	
	cout << "How many will student government contribute? ";
	cin  >> contribution;
	
	r = totalneeded -contribution;
	
	dormnumber = 0;
	while (r > 0)
	{
		cout <<" We still need "<<setw(2)<<r <<" worker";
		if (r >1 ) cout<<"s";
		cout<<".\n";
		dormnumber = dormnumber + 1;
		cout <<"How many will dorm "<<dormnumber<<" contribute? ";
		cin  >> contribution;
		r = r - contribution;
	}
	
	cout <<"Student government";
	if (dormnumber>0)
	{
		cout <<" and the "<<dormnumber<<" dorm";
		if (dormnumber > 1){
			cout << "s";
		}
	}
	cout <<" can run the event";
	
	e = -1*r;
	if (e == 0)											
	{
		cout <<".\n";
	} else {
		cout <<",\nwith "<<e<<" worker";
		if (e > 1) cout << "s";
		cout <<" left over to help with security.\n";
	}
	return 0;
}

/*
bash-2.05$ ./a.out
How many workers are needed? (99 max) 18
How many will student government contribute? 17
 We still need  1 workers.
How many will dorm 1 contribute? 4
Student government and the 1 dorm can run the event,
with 0 worker left over to help with security.
bash-2.05$
*/																  //
