COS 1512 ASSIGNMENT 1
Question 1 //Calculate tuition fees based on number of new modules //and the number of repeat modules #include iostream using namespace std; int calcFees (int numberOfNewModules, float nModFee) { return (numberOfNewModules * nModFee); } int calcFees (int numberOfNewModules, float newModFee, int numberOfRepeatModules, float repeatModFee) { return (numberOfNewModules * newModFee + numberOfRepeatModules * repeatModFee); } int main() { int numberOfRepeatModules, numberOfNewModules; float tuitionFeeNew, tuitionFeeRepeat; const float repeatModuleFee = 500.00; const float newModuleFee = 800.00; char repeatingModules; cout "Are you repeating any modules? " endl ; cout "If yes, please enter 'Y', else enter 'N': " endl ; cin repeatingModules; switch (repeatingModules) { case 'y': case 'Y': cout "How many modules are you repeating? "; cin numberOfRepeatModules; break; case 'n': case 'N': numberOfRepeatModules = 0; break; default: cout "Please only answer with 'Y' or 'N'" endl ; } This study source was downloaded by from CourseH on :34:44 GMT -05:00 This study resource was shared via CourseH cout "How many modules are you taking for the first time? " endl ; cin numberOfNewModules; tuitionFeeNew = calcFees(numberOfNewModules, newModuleFee) ; tuitionFeeRepeat = calcFees(numberOfNewModules, newModuleFee, numberOfRepeatModules, repeatModuleFee) ; (ios::fixed); sion(2); if (numberOfRepeatModules == 0) cout endl "Your total tuition fee will be: R" tuitionFeeNew endl; else cout endl "Your total tuition fee will be: R" tuitionFeeRepeat endl; return 0; } Input and Output: (a) Are you repeating any modules? If yes, please enter 'Y', else enter 'N': y How many modules are you repeating? 3 How many modules are you taking for the first time? 3 Your total tuition fee will be: R3900.00 Press any key to continue . . . (b) Are you
Written for
- Institution
-
Johns Hopkins University
- Course
-
COS 1512 ASSIGNMENT 1
Document information
- Uploaded on
- September 9, 2021
- Number of pages
- 5
- Written in
- 2021/2022
- Type
- Exam (elaborations)
- Contains
- Questions & answers