Algorithm
problem Link : https://www.codechef.com/problems/HS08TEST
Problem
Pooja would like to withdraw Xhttps://www.codechef.com/problems/HS08TESTl only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges 0.50 $US.
Calculate Pooja's account balance after an attempted transaction.
Input Format
Each input contains 2 integers and .
is the amount of cash which Pooja wishes to withdraw.
is Pooja's initial account balance.
Output Format
Output the account balance after the attempted transaction, given as a number with two digits of precision. If there is not enough money in the account to complete the transaction, output the current bank balance.
Constraints
- - the amount of cash which Pooja wishes to withdraw.
- with two digits of precision - Pooja's initial account balance.
Sample 1:
30 120.00
89.50
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int x;
float y,z;
scanf("%d %f",&x,&y);
if(x%5==0 && x<=y-0.50)
{
z=y-x-0.50;
printf("%.2f\n",z);
}
else
{
printf("%.2f\n",y>;
}
}
Copy The Code &
Try With Live Editor
Input
Output
Demonstration
CodeChef solution HS08TEST ATM - HS08TEST ATM solution in C,C++