Please Fill out the Feedback Form for Code Radius

ATM : HS08TEST | Codechef Solution

2 min read

Problem

Pooja would like to withdraw X $US from an ATM. The cash machine will 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

Positive integer 0 < X <= 2000 - the amount of cash which Pooja wishes to withdraw.
Nonnegative number 0<= Y <= 2000 with two digits of precision - 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

Sample

Input
30 120.00
Output
89.50

Explanation

Solution

cpp
#include <iostream> using namespace std; // Solution from : Code Radius [ https://radiuscode.blogspot.com/ ] int main() { int w; float ac_bl; cin>>w; cin>>ac_bl; if(w%5==0 && w<=ac_bl-0.5){ cout<<((ac_bl-w)-(0.5)); } else{ cout<<ac_bl; } return 0; }

Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem Write a program to obtain a number NN and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1. Please Share this article... …
  • Problem Write a program to take two numbers as input and print their difference if the first number is greater than the second number otherwise print their sum. Please Share…
  • Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.Relational Operators are operators which check relati…
  • Problem Pooja would like to withdraw X $US from an ATM. The cash machine will only accept the transaction if X is a multiple of 5, and Pooja's account balance has enough cash …
  • Problem The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Ou…
  • Problem In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b seconds are added to this player's clock. Ti…

Post a Comment