can some1 help me, i'll give the question..huhu

Write nested if statement that perform the following test: if the variable employed is equal to 'Y' and worklength is equal to or greater than 5, then display the message "your credit card application is accepted". however,if worklength is less than 5, then display the message "please provide a guarantor". otherwise, if the variable employed is equal to 'N' , then display the message "your credit card application is rejected".
Last edited on
we don't do your homework...
try something yourself first
1
2
3
4
5
6
7
8
9
10
if (theVariableEmployed == 'Y')
{
    if (worklength >= 5)
        std::cout << "your credit card application is accepted";
    else
        std::cout << "please provide a garantor";
}
else
if (theVariableEmployed == 'N')
    std::cout << "your credit card application is rejected";

catfish2: I actually have tried it before, i can compile my program code but it wont display the cout statement.

i wrote it like that, but i just dont put the 'std::cout' wht is it for?
thank u for ur help ^^
Last edited on
std::cout represents the "console output".
And if you have a using namespace std; you can write just cout without std::.
To use std::cout, you must #include <iostream> .

Anyway, from what I can tell, you start your program but the window disappears too fast and you can't read what it says?
If so, read this: http://cplusplus.com/forum/beginner/1988/

Otherwise give more details.
perhaps i can show u my code, so that, u can fix it for me...?

#include<iostream>
using namespace std;
int main()
{
char theVariableEmployed;
double worklength;
char Y,N;

cout<<"Enter employee variable either Y or N : ";
cin>>theVariableEmployed;
cout<<"Enter worklength: ";
cin>>worklength;

if (theVariableEmployed == 'Y')
{
if (worklength >= 5)
cout << "your credit card application is accepted";
else
cout << "please provide a garantor";
}
else if (theVariableEmployed == 'N')
cout << "your credit card application is rejected";


system("pause");
return 0;
}
Last edited on
If you're using very old tools, you may need to flush std::cout.
In your case, add before system("pause"); cout.flush();

Otherwise I don't see problems.

Edit: be sure you enter UPPERCASE Y OR N AND NOT lowercase y or n.
Last edited on
well, the output not displaying the 'cout statement'
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
#include<iostream>
using namespace std;

int main()
{
    char   theVariableEmployed;
    double worklength;
    char   Y,N;

    cout << "Enter employee variable either Y or N : ";
    cin  >> theVariableEmployed;
    cout << "Enter worklength: ";
    cin  >> worklength;

    if (theVariableEmployed == 'Y' || theVariableEmployed == 'y')
    {
        if (worklength >= 5)
            cout << "your credit card application is accepted";
        else
            cout << "please provide a guarantor";
    }
    else
        if (theVariableEmployed == 'N' || theVariableEmployed == 'n')
            cout << "your credit card application is rejected";
        else
            cout << "No output";

    cout.flush();

    system("pause");
    return 0;
}
Thank u very much chervil., this is very helpful.^^

i wonder, why i cnt get the same output with my program?
Ask clear questions. What do you want to achieve? What is not working the way you want it to?
Topic archived. No new replies allowed.