Answer to Question #213478 in C++ for Safrina

Question #213478

Due to lockdown, AB bank handles a limited number of customers each day (30 persons). To maintain social distance, these persons enter into the bank in 3 rounds. First, 10 people go and perform their task one after one. After 2 minutes, one of them leave the bank finishing their work. When all of the 10 persons leave the bank, 10 more people enter into the bank and perform their work. This continues until all the 30 people are served. 

Write a program that automates this task. It will store the name of the customers who are entering the bank. When the quota of 10 persons gets filled up, it will prevent others from entering the bank. After each 2 minutes, the program will print the name of the customer who is about to leave the bank. When the bank will be empty, it will let 10 more people enter into the bank. After serving 30 people, it will announce that bank is closed for the day


1
Expert's answer
2021-07-05T06:51:18-0400
#include <upstream>

using namespace std;
int findsequence(unsigned v)
{
    int d0 = v % 10; v /= 10;
    int d1 = v % 10; v /= 10;
    int d2 = v % 10; v /= 10;
    int d3 = v % 10; v /= 10;


    if(d3 >= d2 && d2 >= d1 && d1 >= d0)
    {
        return 2;
    }
    else
    if(d3 <= d2 && d2 <= d1 && d1 <= d0)
    {
        return 1;
    }
    
    return 0;
}


int main()
{
    cout << "Enter 4-digit integer: ";
    unsigned value;
    cin >> value;
    if(!cin || value > 9999 || value < 1000)
    {
        cout << "Bad input!\n";
        return 1;
    }


    cout << "findsequence(" << value << ") = " << findsequence(value) << "\n";
    
    return 0;    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS