Free Essay

# Prg/211 Calorie Count Tool

Submitted By motojunkii
Words 1524
Pages 7
Team B Calorie Count Tool
PRG/211
May 5, 2014

Team B Calorie Count Tool
PROBLEM STATEMENT
Team B was asked to develop a program which would calculate the user’s daily intake of calories and measure those calories against the overall calories expended. The core purpose of this program will do two primary functions. First, it will record the user intake of calories as acquired through meals throughout the day. Second, the user will record caloric output associated with physical activity. This information will be calculated together to determine the caloric surplus or deficit for the user.

In order for the program to execute accurately, and provide customized results, the user will be required to input personal data to include gender, age, weight, and height. This additional information is essential to determine the user’s default caloric burn rate, otherwise known as the basal metabolic rate (BMR). The BMR and the calories burned as a result of physical activity will be calculated against the intake of calories to determine the overall success for the user.
As the program is executed it must: * Record user name, age, height, weight to enable more accurate calculations * Record the users specific caloric values entered for each meal * Record the user activity and caloric burn values for that activity * Calculate the basal metabolic rate (BMR) for the individual * Subtotal the total caloric values for the day * Combine the physical activity and the BMR to determine overall caloric burn for the day * Display a daily summary for the user to outline level of success

OVERVIEW This program was developed to provide the user a tool to monitor and calculate a caloric surplus or deficit for the day for an individual user. What makes this program different from many others is the additional step of determining the basal metabolic rate (BMR) of the user. “BMR is often regarded as a minimal rate of metabolism compatible with basic processes necessary to sustain life” (Speakman, Elzbieta, & Johnson, 2004, para. 1). Simply put, this is the amount of calories an individual burns without considering any additional physical activity. By calculating the user BMR as well as recording the calories burned as a result of exercise, the user will attain an accurate result of overall caloric surplus or deficit for the day. Upon execution of the program, the user will be introduced to a main navigation menu. At this menu, the user can choose to choose to do a variety of functions to include user setup, record intake, record activity, view results and exit. As the user progresses through the program, they are able to access this main navigation menu at any time, allowing the user to update previously input data at any time.

The intake menu will allow the user to detail meal descriptions with resulting caloric values and the activity menu provides the user with an opportunity to record the caloric value associated with any physical activity for that day. The program will take both of these important values, as well as the determined BMR and determine an overall caloric burn value for the day. The results menu compiles and calculates all the data collected throughout the program and provides the user with an appropriate success message according to the user’s deficit or surplus of calories. If the user has created a deficit of calories for the day, it will be considered a successful day and a resulting message will be displayed. If the user creates a surplus of calories, an unsuccessful message will be displayed as well as an encouraging statement to try again tomorrow.

MODULES
The program is designed by utilizing five core modules, which include a menu module, user data module, intake module, activity module, and a results module. Each module performs a specific task to assist in collecting, compiling, calculating and displaying the results. Rather than writing the code in one long, linear statement, they have been broken down into smaller, task specific modules. As a result, each module can be called upon or re-used at any point or at any time throughout the program. This method is commonly referred to as the divide and conquer method and incorporates many benefits including simpler code, reusability, and easier debugging (Gaddis, p. 76, 2010).

The navigation menu module is considered the hub of this calorie tracker program. All modules direct back to the main menu in order to simply the input for the user. The user will be presented with five options, which execute by use of the if-then-else statement. In this type of structure, the first statement is tested, and if it tests true, it executes. However, if the statement tests false, the second statement is then tested. This process continues at each else clause until either one of the statements tests as true, or the final else statement is executed. Rather than using the more complicated nested if statement, this structure results in a simpler design by keeping the code less complicated for the programmer (Gaddis, p. 140-141, 2010).

The user will typically start with the first navigation choice (userInfo), where they will be prompted for information specific for the user. This module collects the relevant information and stores it in memory by use of declaring and assigning variables. As the user progresses through the module, values are assigned for each variable, such as age, weight, height and gender. However, since these variables will be used outside this module, they must be made public by declaring them in the main module of the program. An example of this can be found with the variable, userAge. This variable alone and it is current state remains private and unavailable to other parts of the program. In order to resolve this, an assignment statement is used, set pubUserAge == userAge. The new assignment of pubUserAge is stored in the main module, which then allows the variable to be used globally. Without this assignment, the value stored in the variable userAge stays contained in this module only and is useless in other parts of the program.

The intake module (modIntake) could be the most complicated of all the modules in the program. This is because it makes use of arrays, which allow the user to store many different values, or elements, under the same variable name. This can be particularly useful when processing large amounts of information, by simplifying the variable names. A parallel array is very similar, but allows the user to assign many variables which may be related to each other by assigning them individual subscripts to the variable names. The parallel array was chosen for this module in order to handle the potentially large number of food entries and calorie values. What makes this module particularly useful, is the ability for the user to control the array size by entering the number of meal items to input. As the user chooses the number of meal items, the program will build an array specific to that size and initiate a for loop with the appropriate number of loops to gather the exact number of meal items and related caloric values. Like other modules in this program, it also uses the if-then-else statements to navigate through the meal choices of breakfast, lunch, dinner and snacks.

As the intake menu is the most complicated, the activity module could be considered the most simple in the program. It is constructed of one variable which stores the value for calories burned as a result of physical activity. However, because this program calculates the users BMR value automatically, this activity value should only contain the value for exercise or other physical activity. This module also utilizes the assignment statement, set pubActivity == activity. As mentioned previously, this stores the variable globally, in the main module, allowing them to be used elsewhere in the program.

The results menu delivers the results to the user and processes one of two messages for success. This is achieved by use of a simple if-else statement. If the calories burned exceed the calories consumed, the statement tests true and the appropriate success message is delivered. If the consumed exceed the calories burned, and unsuccessful message is delivered with additional words of encouragement. This is where the public variables that were previously declared with the pub and public prefixes become most important. The results module is able to reference those previously stores values stored in the main module in order to perform the final calculations.

Rather than simply ending once the results are provided, the friendly design of this module allows the user the option to navigate back to the main menu rather providing for an exit only option. This would provide the user an opportunity to start again or change user settings if needed.

References
Gaddis, T. (2010). Starting Out with Programming Logic & Design (2nd ed.). Retrieved from The University of Phoenix eBook Collection database.
Speakman, J., Elzbieta, K., & Johnson, M.S. (2004, November/December). The Functional Significance of Individual Variation in Basal Metabolic Rate. Physiological and Biochemical Zoology, 77(6), Retrieved from http://www.jstor.org.ezproxy.apollolibrary.com/stable/10.1086/427059