CS 171 Computer Programming 1 Winter 2017 Assignment 3 Loop
CS 171 Computer Programming 1 Winter 2017 Assignment 3: Loops and Reference Parameters
This assignment involves designing, implementing, debugging, and documenting a C++ program that uses loops and reference parameters. The core task is to create functions that calculate blood alcohol concentration (BAC) based on user input and output a comprehensive impairment chart.
Paper For Above instruction
The primary objective of this assignment is to develop a C++ program that accurately models and computes a person's blood alcohol concentration (BAC) based on inputs such as weight, gender, number of drinks, and time elapsed since the last drink. This involves implementing several functions, including those that perform BAC calculations, determine impairment messages, prompt user inputs, and display an impairment chart. The project emphasizes effective use of loops, functions with reference parameters, and careful formatting of output to ensure clarity and precision.
The foundational aspect revolves around calculating BAC. The model considers that each drink contributes a proportional amount of alcohol to the bloodstream, factoring in the person’s weight and gender-specific constants. The consumption and clearance over time are dynamic; BAC increases with drinks consumed and decreases as time passes, modeled by a fixed rate of reduction per 40 minutes of abstinence post-drinking. Proper mathematical implementation of these relationships ensures accurate output that aligns with legal and safety standards.
Function specifications include:
- computeBloodAlcoholConcentration: Calculates BAC for male and female, given number of drinks, weight, and elapsed time, returning results via reference parameters.
- impairment: Returns a message string corresponding to the BAC level as per predefined thresholds.
- promptForInteger, promptForMorF, and showImpairmentChart: User input handling, display formatting, and chart output functions.
The final program involves prompting the user to input weight, time since last drink, and gender, followed by displaying a BAC table with corresponding impairment messages. The program emphasizes proper coding practices, coding style, documentation, and comprehensive testing. Submissions include source code, user and system manuals, and test logs with screenshots to demonstrate functionality.
References
- G. K. Mahajan, "Introduction to Programming with C++," 7th Edition, McGraw-Hill Education, 2015.
- G. L. Steele, "C++ Programming: From Problem Analysis to Program Design," 4th Edition, Cengage Learning, 2018.
- J. L. Lyons, "Programming in C++," Addison-Wesley, 2017.
- B. W. Kernighan and D. M. Ritchie, "The C Programming Language," 2nd Edition, Prentice Hall, 1988.
- H. M. Deitel and P. J. Deitel, "C++ How to Program," 10th Edition, Pearson, 2019.
- J. Stroustrup, "The C++ Programming Language," 4th Edition, Addison-Wesley, 2013.
- O. P. Chaurasia, "Computer Programming: An Introduction," Springer, 2020.
- R. S. Pressman, "Software Engineering," 8th Edition, McGraw-Hill Education, 2014.
- S. L. Toth and K. G. Shafer, "Design and Implementation of User-Friendly Software," IEEE Software, 2019.
- ISO/IEC 14882:2017, "Programming Languages — C++," International Organization for Standardization.