Solution for Codechef HS08TEST | ATM

Hello Programmers,

The solution for codechef ATM problem is given below.

Problem Link:- https://www.codechef.com/problems/HS08TEST

/*
*   Author:- Rahul Malhotra
*   Source:- Programming Vidya
*   Description:- Solution for Codechef ATM problem
*   Problem Link:- https://www.codechef.com/problems/HS08TEST
*   Website:- www.programmingvidya.com
*/

#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
    // * Initializing variables
    float balance;
    int amount;

    // * Accepting the amount  and initial balance
    cin>>amount>>balance;

    /*
    *   If amount is invalid or there are insufficient funds,
    *   display the current bank balance
    */
    if(
        amount%5!=0 ||
        (amount+0.5) > balance
    ) {
        printf("%.2f", balance);
    }

    // * Otherwise, display the balance after transaction
    else
    {
        printf("%.2f", (balance-amount-0.5));
    }

    return 0;
}

Happy Coding..!!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s