//******************************************************************************** // Author: Zhixiang Chen // Class: CSCI/CMPE 1170, Spring 2009 // Lab 17: More modular design and functions // Date: January 2009 // Revised on: 06/26/2009 by sirisha surisetty // Comment: The code here is meant to be revised. // //-------------------------------------------------------------------------------- // // This lab exercise is to show modular design to solve the problem of // designing and implementing a simple math game. The game trains the user // to practice arithmetic operations of +, -, * and /. For each operation, // the program generates two random integers with signle digit and asks the result // from the user. The program keeps statistical info about the user's performance. // // Compile and run your program. When everything is fine, // print your .cpp file and turn it to me or the TA. // ******************************************************************************** #include #include #include #include #include #include #include //include header file #include "lab_17_head.h" using namespace std; int main( ) { //variable declaration int number1, number2; //vars to store int values double intResult, doubleResult; //vars to store the result char action; //var for store the operator char flag; //var to stor the choice int plusWins, plusLosses, plusTotal, //plus stats for winning, losing, and total games played minuWins, minuLosses, minuTotal, //minus stats for winning, losing, and total games played multWins, multLosses, multTotal, //multiplication stats for winning, losing, and total games played diviWins, diviLosses, diviTotal; //division stats for winning, losing, and total games played double answer; //var for answer from the user //initializations plusWins = plusLosses = plusTotal = 0; minuWins = minuLosses = minuTotal = 0; multWins = multLosses = multTotal = 0; diviWins = diviLosses = diviTotal = 0; //show welcome message welcome(); //enter your choice getChoice(flag); //start loop to play the game while(flag=='y' || flag=='Y') { //get operator getOperator(action); //four cases for action switch(action) { case '+': //do addition //get two random numbers of two digits getTwoNumbers(number1, number2); //add intResult = add(number1, number2); //getAnsers from the user getAnswer(number1, number2, action, answer); //win or loss addGame(intResult, static_cast(answer), plusWins, plusLosses, plusTotal); break; case '-': //do substraction //get two random numbers of two digits getTwoNumbers(number1, number2); //add intResult = minus(number1, number2); //getAnsers from the user getAnswer(number1, number2, action, answer); //win or loss minuGame(intResult, static_cast(answer), minuWins, minuLosses, minuTotal); break; case '*': //do multiplication /*************************************************** This part is for you to complete ***************************************************/ cout<<"This part is for you to complete"<