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

  •  ProblemChefland has 2 different types of coconut, type A and type B. Type A contains only x_a milliliters of coconut water and type B contains only x_b grams of coconut pulp.…
  • ProblemIf Give an integer N . Write a program to obtain the sum of the first and last digits of this number. Please Share this article... Input Format The first line contains a…
  • ProblemAlice and Bob are meeting after a long time. As usual they love to play some math games. This times Alice takes the call and decides the game. The game is very simple, Alice…
  • ProblemYou and your friend are playing a game with hoops. There are N hoops (where N is odd) in a row. You jump into hoop 1, and your friend jumps into hoop N. Then you jump into h…
  •  ProblemChef is a big fan of Coldplay. Every Sunday, he will drive to a park taking M minutes to reach there, and during the ride he will play a single song on a loop. Today, …
  •  ProblemWrite a program to obtain length (L) and breadth (B) of a rectangle and check whether its area is greater or perimeter is greater or both are equal. Please Share thi…

Post a Comment