Sunday, April 18, 2010

How To Hang A Scarf Valence

ATM using Conditional

The following program simulates a cashier, in which the user enters the number corresponding to the desired action.
In this case, the example is done with Conditional , ie IF instruction.
 # Include \u0026lt;iostream.h>   
/ / Declaration of input and output variables

INT a = 0, / / \u200b\u200bDefault Value Assigned to Variable A

INT main (void) {


/ / Join the User variables

court \u0026lt;\u0026lt;"Welcome to the cashier who is not going to steal a single dollar" \u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;"Please Choose what to do: "\u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl; / / Text Request

court \u0026lt;\u0026lt;" 1. Remove Cash "\u0026lt;\u0026lt;endl; / / Text Request
court \u0026lt;\u0026lt;" 2. Appropriation "\u0026lt;\u0026lt;endl; / / Text Request
court \u0026lt;\u0026lt;" 3. Check your balance "\u0026lt;\u0026lt;endl; / / Text Request
court \u0026lt;\u0026lt;" 4. Change password "\u0026lt;\u0026lt;endl; / / Text Request
court \u0026lt;\u0026lt;" 5. Payment for services "\u0026lt;\u0026lt;endl \u0026lt;\u0026lt;endl; //Texto of Request
cin>> a; / / Save First Choice

IF (a == 1) {

court \u0026lt;\u0026lt; ; "You have chosen to withdraw cash" \u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;"Thank you for visiting" \u0026lt;\u0026lt;endl;}




ELSE IF (a == 2)

{court \u0026lt;\u0026lt;"You have decided to enter" \u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;"Thank you for visiting" \u0026lt;\u0026lt;endl;}




ELSE IF ( a == 3)

{court \u0026lt;\u0026lt;"You has decided to consult balance "\u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;" Thank you for visiting "\u0026lt;\u0026lt;endl;}




ELSE IF (a == 4) {

court \u0026lt;\u0026lt;"You have decided to change your password" \u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;"Thank you for visiting" \u0026lt;\u0026lt;endl;}



ELSE IF {
(a == 5) {

court \u0026lt;\u0026lt; "You have chosen to pay for services" \u0026lt;\u0026lt;endl;
court \u0026lt;\u0026lt;"Thank you for visiting" \u0026lt;\u0026lt;endl;}


ELSE
court \u0026lt;\u0026lt;"The selected option is not valid "\u0026lt;\u0026lt;endl;}



system (" pause ");
Return 0;}

In this case, you'll see used NESTED IF (one inside another IF IF) to determine the option deposit, and in the end, it leaves a ELSE in case the user did not enter an option or assigned at first.

0 comments:

Post a Comment