What's new

Closed ATM c++ using switch and loop

Status
Not open for further replies.

Lenardkun

Honorary Poster
Joined
Sep 23, 2018
Posts
161
Reaction
20
Points
154
Age
23
Patulong po kung pano gumawa ng ATM c++ using switch and loop. Groupings po kasi to kaso ala pong gustong maki group sakin. kaya dito nalang po ako nag ask ng help. sana po matulungan nyo po ako. Willing po ako matuto kahit medyo slow learner po ako
 
Use while loop for the attempts then inside the loop use else if statements.
Ganito ang condition sa while loop:

C++:
while (count != 0) {
    
    // insert enter pin here

    if () {
        
        // insert ATM functions here
        
    } else {
        
        // insert remaining attempts here, (count - 1)
        
    } 
    count--;
}

 

Attachments

may tanong lang po ako, kapag natapos na ko yung transactions pano ko po maibabalik ulit dun sa menu ano po gagamitin ko?
 
pano po gawin yun? sorry po talaga

C++:
int option; // this will hold the input value for the options

while (count == 0) {
   
    // enter pin number here
   
    if (pinNumber == pass) {
       
        while (true) {
           
            // insert ATM menu here

            
           // here if the user enter 0 this will exit the program.
           if (option == 0) {
           
            return 0;
       
           // if the user enter 1 this will do some ATM functions | see example below
           } else if (option == 1) {
           
           } else if (option == 2) {
            // more ATM functions
           }
       
          // and so on ...
           
        }
       
    }
   
}



Your program will only exit if the user chooses the option for exit.
 

Attachments

Last edited:
Dapat may else ka na mag hahandle ng ibang input so pag hindi nag input yung user ng integer mag lalabas ng error yung else statement.
 
sir last na tanong na po. hindi ko po talaga maayos yung error dun sa wí†hdráw and deposit. kapag naglagay ko ng Letters nag error yung program hindi na makaalis sa wí†hdráw or deposit. pano ko kaya to maayos? eto nalang po problem dun sa code
 
Status
Not open for further replies.

Similar threads

Back
Top