Week05Assignment.cpp
// The MakePurchase function which will sell the surfboards
// Added XXXS as an option for MakePurchase
The MakePurchase function which will sell the surfboards
Added XXXS as an option for MakePurchase
The MakePurchase function which will sell the surfboards Added XXXS as an option for MakePurchase
void MakePurchase(int& iTotalSmall, int& iTotalMedium, int& iTotalLarge, int& iTotalXXXS) {
    int quantity;
    string size;
    cout << "Please enter the quantity and type (X=XXXS, S=small, M=medium, L=large) or surfboard you would like to purchase: ";
    cin >> quantity;
    cin >> size; 
    transform(size.begin(), size.end(), size.begin(), ::toupper);
    if (size == "S") {
        iTotalSmall = iTotalSmall + quantity;
    }
    else if (size == "M") {
        iTotalMedium = iTotalMedium + quantity;
    }
    else if (size == "L") {
        iTotalLarge = iTotalLarge + quantity;
    }
    else if (size == "X") {
        iTotalXXXS = iTotalXXXS + quantity;
    }
    else {
        cout << "Wrong input, exiting program..." << endl;
        system("pause");
    }
}
void MakePurchase ( int & iTotalSmall , int & iTotalMedium , int & iTotalLarge , int & iTotalXXXS ) { int quantity ; string size ; cout << " " ; cin >> quantity ; cin >> size ; transform ( size . begin ( ) , size . end ( ) , size . begin ( ) , :: toupper ) ; if ( size == " " ) { iTotalSmall = iTotalSmall + quantity ; } else if ( size == " " ) { iTotalMedium = iTotalMedium + quantity ; } else if ( size == " " ) { iTotalLarge = iTotalLarge + quantity ; } else if ( size == " " ) { iTotalXXXS = iTotalXXXS + quantity ; } else { cout << " " << endl ; system ( " " ) ; } }
The MakePurchase function which will sell the surfboards
Added XXXS as an option for MakePurchase
The MakePurchase function which will sell the surfboards Added XXXS as an option for MakePurchase
// We need two inputs, quantity and size // Ask the user for their input // Added XXXS as an option for the input // CAST TO UPPER // We need to keep a count of how many of each type of surfboard was purchased // I used an if statement to do this // If size is small, add the quantity to the counter iTotalSmall // If size is medium, add the quantity to the counter iTotalMedium // If size is large, add the quantity to the counter iTotalLarge // else if statement for the xxxs size // Default case to exit program if user enters wrong input