What is wrong with my program?

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#define percent 0.01
#include <cstdlib>
#include <iostream>
using std::cout;
using std::cin;

double percentify(double PBP) // Percent Before Percentified
{
    double PAPAPPY = 0; // Percent After Percented APPY
    PAPAPPY = PBP * percent;
    return PAPAPPY;
}

double tax(double TBP, double MABT) // Tax Before Percentified, Money Amount Before Tax
{
    double TAAP = 0; // Tax Amount After Percent
    double TMAAT = 0; // Tax Money Amount After Tax
    double MAAT = 0; // Money Amount After Tax
    TAAP = percentify(TBP);
    TMAAT = TAAP * MABT;
    MAAT = TMAAT + MABT;
    return MAAT;
}

double POC(double ON, double NN) // POC is Percent Of Change, ON is Original Number, NN is New Number
{
    double subAmount = 0;
    double xAmountOfChange = 0;
    if (ON>NN)
    {
        subAmount = ON - NN;
        xAmountOfChange = (100 * subAmount)/ ON;
    }
    if (NN>ON)
    {
        subAmount = NN - ON;
        xAmountOfChange = (100 * subAmount)/ ON;
    }
    if (NN==ON)
    {
        subAmount = 0;
        xAmountOfChange = 0;
    }
    return xAmountOfChange;
}

bool isItPositive (double ON , double NN) // ON is original number, NN is new number
{
    bool yesorno = true;
    if (NN<ON)
        yesorno = false;
    if (ON<NN)
        yesorno = true;
    if (ON == NN)
        yesorno = true;
    return yesorno;
}

bool questioner ()
{
    char recordLetter = ' ';
    double enterOriginalBeforeTax = 0;
    double enterTaxPercent = 0;
    double enterOriginalNumber = 0;
    double enterNewNumber = 0;
    cout << "/nIf you want to do Tax, press T. If you want to do percent of change, press P. If you want to quit, press Q./n";
     cin >> recordLetter;
    if (recordLetter == 'T')
    {
        cout << "Enter Tax, but not in percent./n";
         cin >> enterTaxPercent;
        cout << "Enter the money amount before tax./n";
         cin >> enterOriginalBeforeTax;
        cout << enterTaxPercent << "% +" << enterOriginalBeforeTax << "=";
        cout << tax(enterTaxPercent,enterOriginalBeforeTax);
        cout << "/n";
        cout << "Would you like to enter a new question? If so, press A, otherwise, press Q to quit./n/n/n";
        recordLetter = ' ';
         cin >> recordLetter;
        if (recordLetter == 'A')
        {
           recordLetter = ' ';
           questioner();
        }
        if (recordLetter == 'Q')
        {
            return true;
        }

    }
    if (recordLetter == 'P' )
    {
        cout << "enter original number/n";
         cin >> enterOriginalNumber;
        cout << "enter new number";
         cin >> enterNewNumber;
        if (enterOriginalNumber > enterNewNumber)
        {
            cout << enterOriginalNumber << "-" << enterNewNumber << "=" << enterOriginalNumber - enterNewNumber << "over" << enterOriginalNumber << "equals";
        }
        if (enterNewNumber > enterOriginalNumber)
        {
            cout << enterNewNumber << "-" << enterOriginalNumber << "=" << enterNewNumber - enterOriginalNumber << "over" << enterOriginalNumber << "equals";
        }
        cout << POC(enterOriginalNumber, enterNewNumber) << "/n";
        cout << isItPositive(enterOriginalNumber,enterNewNumber);
        cout << "Would you like to enter a new question? If so, press A. Otherwise, press Q to quit. /n/n/n";
        recordLetter = ' ';
         cin >> recordLetter;
        if (recordLetter == 'A')
        {
            recordLetter = ' ';
            questioner();
        }
        if (recordLetter == 'Q')
        {
            return true;
        }

    if (recordLetter == 'Q')
    {
        return true;
    }
    }

}

int main ()
{
    bool didQuestionerWork = false;
    didQuestionerWork = questioner();
    if (didQuestionerWork == true)
    {
        return 0;
    }
    else if (didQuestionerWork == false)
    {
        return 1;
    }

}

tried to run this, codeblocks said something like cannot open ld.
closed account (S6k9GNh0)
ld is your linker. It happens outside of C++.

EDIT: Your project does compile under pedantic and Wall: http://liveworkspace.org/code/38IS1K$0

I'm not sure the intended output, just that it compiles.
Last edited on
First, do new line it's \n, not /n. If you can't remember that, do
cout << endl;
Second, I have codeblocks too and it works fine, copy code, then make new project, you might have clicked something wrong, then paste code in new project. Or reinstall codeblocks
Topic archived. No new replies allowed.