#Y/N to continue

1 messages · Page 1 of 1 (latest)

long notch
#
using namespace std;

int main()
{
    cout << "Loan Interest Calculator" << endl; //prompted when opened//
    char Letters;
    double Amount;
    double rate;
    double years;
    cout << "Would You Like To Continue? [Y] Yes, [N] No." << endl;
    cin >> Letters;

    cout << "How Much Is it originally: $";
    cin >> Amount;

    cout << "Rate, Example (3.56) ";
    cin >> rate;

    cout << "How Many Years, If including months find the decimal of months out of the year" << endl;
    cin >> years;

    double total = Amount * rate * years;
    
    cout << "Total Payment(WITH INTEREST): $" << total << endl;

    system("pause");
        return 0;
}```
#

Thats the code.

solid epoch
#

whats the question

long notch
#

I waNt it so whenever I type in Y it continues.

#

if N it leaves.

#

very confused on that.

solid epoch
#

have you considered comparing the input to y and n

long notch
#

i don't know how to do that, yesterday i learned the basics of c++

#

I know a little bit.

#

i've made a few programs.

solid epoch
#

did you get to if else statements yet

#

and operators

long notch
#

no, but I did another program that includes that.

solid epoch
#

you should learn those before writing anything

#

because those are essential to programming itself

long notch
#

alright.

#

could you explain?

#

cause youtube does a horrible job.

solid epoch
#
if (condition)
  {
    //code if condition is true
  }
else 
  {
    //code if condition is not true
  }
long notch
#

makes sense.

#

how would i get the keybind function.

#

I am pretty sure i have to include something right?

solid epoch
#

keybinds?

long notch
#

yeah like

#

Y keybind

#

N keybind

#

y continues

#

N exits

#

the cmd

solid epoch
#

you already have that

#

with cin >>

long notch
#

Oh.

solid epoch
#

you just need to compare it Y or N

#

Also not just if and else, theres a lot of structures you need to learn like

#

While loops
For Loops

#

you should learn structs and classes as well

#

You need to learn more because these are really important for doing basic things

#

also for operators: *, ==, &&, ||

#

I recommend learncpp or just looking at documentation

long notch
#

is that a good start?

solid epoch
#

yes

long notch
#

alright, thanks for taking your time to help a newbie😁

solid epoch
#

np

long notch
#

Also.

#

How would I exit the program if the keybind y isn't detected.

#

so if they press z'

#

or n

#

it'll just close

#

exit()?

#

exit(0);

solid epoch
#

you would use else and then do exit(errorcode)

#

with errorcode being some integer

long notch
#

ok makes sense.

#

has to be greater than 0?

#

correct.

solid epoch
#

it can be anything

long notch
#

oh alright.

solid epoch
#

but 0 is generally used for exit success

long notch
#

alright.

#

dude

#

I just wanna say thanks to you.

#

without you i would of been going through 10 million forums getting nothing.

#

it works!

#

if u do any other keybind it just exits

solid epoch
long notch
#

alright.

solid epoch