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..!!