//Program : functionsCoding1.cpp //Author : Justin Senseman //Due : November 15, 2005 //Description : This program converts military time to civilian time #include #include using namespace std; #define ADULT .25 //daily late fee for adult books #define CHILDREN .05 //daily late fee for childerns books #define VIDEO_DVD 2 //daily late fee for video of dvd char getMedia(); int getDays(); double getTotal(char media,int days); void pintTotal(int counter,double grandTotal); int main () { int counter=0, // count how many tmes user repeats the loop days; // stores number of inputed days double total, // stores total grandTotal=0; //stores running total char media, //stores type of media answer; //stores users input for reapting the loop do { media= getMedia(); days= getDays(); total=getTotal(media,days); grandTotal+=total; counter++; cout<<"\nDo you have additional overdue items (y)es or(n)o? : "; cin>>answer; } while (answer=='y'||answer=='Y'); pintTotal(counter,grandTotal); return 0 ; } // Function : getMedia // Purpose : Obtain & validate users choice for media // input : none // output : choice - users input for type of media char getMedia() { char choice; cout<<"what type of media are you returning ?\n"; cout<<"(A)dult\n(C)hildren\n(V)ideo or DVD:"; cin>>choice; while(choice!='A'&&choice!='C'&&choice!='V'&&choice!='a'&&choice!='c'&&choice!='v') { cout<<"Error you entered an invalid choice\n"; cout<<"what type of media are you returning ?\n"; cout<<"(A)dult\n(C)hildren\n(V)ideo or DVD:"; cin>>choice; } return choice; } // Function : getDays // Purpose : obtain & validate users input for number of days media is late // input : none // output : days - number of days media is late int getDays() { int days; //stores number of days media is late cout<<"\nEnter number of days media is late :"; cin>> days; while(days<1) { cout<<"\n\nERROR: You enterede an invalid number of days"; cout<<"\n\nEnter number of days media is late :"; cin>> days; } return days; } // Function : getTotal // Purpose : calculates total // input : media - users inputed media // days - users inputed days // output : total - users current total double getTotal(char media,int days) { double total; switch (media) { case 'a': case 'A': if(days>20) total=5; else total=days*ADULT; break; case 'c': case 'C': if(days>20) total=1; else total=days*CHILDREN; break; case 'v': case 'V': if(days>5) total=10; else total=days*VIDEO_DVD; break; } return total; } // Function : printTotal // Purpose : Print the total on the screen // input : counter - total counted items // grandtotal - running total // output : none void pintTotal(int counter,double grandTotal) { cout<<"\n\nTotal number of items returned is "<