0

Hello i'm very new to programming and self teaching myself. I'm having a problem with my project. I'm trying to preform an equation, but every time I

in put the variable it runs to the end. It is a programm to help solve precents

for my friend. This is the code:

```
// Percent
// To find percents by an equation
#include <iostream>
using namespace std;
int main()
{
int percent;
int amount;
int base;
int answer;
cout << "\nThis is a program is to find percents using cross multiplication";
cout << "\nIn this program you will only use the variable 'n'";
cout << "\nThis will use a Precent, Base and Amount";
cout << "\nThe set up of this is like so:\n";
cout << "\n\tP A";
cout << "\n\t- -";
cout << "\n 100 B\n";
cout << "\nWhen using this program only use one variable, because if you";
cout << "use more than one, you will screw it up.";
cout << "\nIf you say p = 'n' and a = 'n' you can't get any product. ";
cout << "It's like Bob Caldwelltrying to tell the weather...it just don't work";
cout << "\n\nEnter the Percent: ";
cin >> percent;
cout << "\nEnter the Amount: ";
cin >> amount;
cout << "\nEnter the Base: ";
cin >> base;
if ( percent == 'n' ) //the equation if percent is 'n'
{
answer = 100 * amount /base;
cout << "\n\nThe answer is: " << answer << " %" << endl;
}
if ( amount =='n' ) // the equation if amount is 'n'
{
answer =(percent * base) / 100;
cout << "\n\nThe Amount is: " << answer << endl;
}
if ( base == 'n' ) //the equation if the base is 'n'
{
answer = (100 * amount) / percent;
cout << "\n\nThe base is: " << answer << endl;
}
cout << "\n\nAnswer: " << answer; //restate the answer
cout << "\n\nThank you" << endl;
return 0;
}
```

I don't know what to do? can anyone help me. If I enter 'n' as the percent it

runs to the end. It also runs to the end when I enter it in any other field. So please help me. :confused:

*Edited 3 Years Ago by Dani*: Formatting fixed