aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch9-Debugging/CST116-Ch9 Debugging-Pseudocode-Crawford.txt
blob: 091a23e8ee01caceee8e493e9209f16703f28e87 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
Include standard operation parameters
[#include <iostream>
using std::cout;
using std::cin;
using std::endl;]

*Simulate age of person and how old they are in days.
const int DAYS_PER_YEAR = 365;

int GetAge(int &a);
int CalcDays(int age);
void PrintResults(int age, int days);

int main()
{
    int age = 0;
    int days = 0;
    // Breakpoint 1
    // Put breakpoint on the following line 
    cout << "Breakpoint1age=" << age << "days=" << days << "address of age" << &age << endl;

    GetAge(age);
    days = CalcDays(age);

    // Breakpoint 2
    // Put breakpoint on the following line
    cout<<"Breakpoint2age="<< age << "days = " << days << "address of age" << &age << endl;
    PrintResults(age, days);

    return 0;
}
* Part 1&2 Get the age of the user
*return a non-0 on an error, 0 otherwise

int GetAge(int &age)
{
    cout << "Breakpoint age=" << age << "At Address:" << &age << endl;
    cout << "Please enter your age: ";
    cin >> age;
    cout << " Breakpoint age = " << age << " At Address: " << &age << endl;
    return age;
}
*Past section calculates the number of days in years
*set year parameter, Number of Years

int CalcDays(int years)
{
    int days;
    days = years * DAYS_PER_YEAR;

    return days;
}
void PrintResults(int days, int age)
{
    cout << age << "! Boy are you old!\n";
    cout << "Did you know that you are at least " << days << " days old?\n\n";
}
*This prints the number of years & days to the screen with message 
Shows age in days and years.