Single File Programming QuestionPooja would like to withdraw X dollars 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 :The first line contains two inputs separated by a single space: XX and YY.where,XX is the integer representing the amount of cash that Pooja wishes to withdraw.YY is the double type of Pooja's initial account balance.Output format :The output displays 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.Refer to the sample output for formatting specifications.Code constraints :0 <X ≤ 2000 is the amount of cash that Pooja wishes to withdraw.0 ≤ Y≤ 2000 with two digits of precision is Pooja's initial account balance.Sample test cases :Input 1 :30 120.00Output 1 :89.50Input 2 :42 120.00Output 2 :120.00Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characte
Question
Single File Programming QuestionPooja would like to withdraw X dollars 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 :The first line contains two inputs separated by a single space: XX and YY.where,XX is the integer representing the amount of cash that Pooja wishes to withdraw.YY is the double type of Pooja's initial account balance.Output format :The output displays 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.Refer to the sample output for formatting specifications.Code constraints :0 <X ≤ 2000 is the amount of cash that Pooja wishes to withdraw.0 ≤ Y≤ 2000 with two digits of precision is Pooja's initial account balance.Sample test cases :Input 1 :30 120.00Output 1 :89.50Input 2 :42 120.00Output 2 :120.00Note :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characte
Solution
Here is a Python solution for the problem:
def calculate_balance(X, Y):
# Check if the withdrawal amount is a multiple of 5 and if there is enough balance in the account
if X % 5 == 0 and X + 0.50 <= Y:
# If conditions are met, subtract the withdrawal amount and the bank charges from the account balance
Y = Y - X - 0.50
# Return the account balance with two digits of precision
return "{:.2f}".format(Y)
# Test the function with the sample test cases
print(calculate_balance(30, 120.00)) # Output: 89.50
print(calculate_balance(42, 120.00)) # Output: 120.00
This function first checks if the withdrawal amount is a multiple of 5 and if there is enough balance in the account to cover the withdrawal amount and the bank charges. If these conditions are met, it subtracts the withdrawal amount and the bank charges from the account balance. Finally, it returns the account balance with two digits of precision.
Similar Questions
Single File Programming QuestionProblem StatementPranav is playing a coin game with his friends. Create a simple program to assist Pranav in converting a given amount of cash into the minimum number of coins. Prompt Pranav to input the cash amount and utilize assignment operators to calculate and display the minimum number of coins needed for denominations of 100, 50, 10, 5, 2, and 1. Assume these denominations as coins with values of 100, 50, 10, 5, 2, and 1, respectively.Note:Give the input greater than 100.Input format :The input is a single integer c representing the amount of cash.Output format :The output displays the minimum number of rupee notes for denominations of 100, 50, 10, 5, 2, and 1.Refer to the sample output for the formatting specifications.Code constraints :In the given scenario, the test cases fall under the following constraints:100 ≤ c ≤ 10000Do not use any looping structures.Sample test cases :Input 1 :100Output 1 :1Input 2 :589Output 2 :12Input 3 :10000Output 3 :100Code Size : 1024 kbNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Single File Programming QuestionProblem StatementLiam is an international traveller curious about currency exchange rates. Create a simple program to assist Liam in converting a given amount in dollars to Indian Rupees. Input the amount in dollars and display the equivalent amount in Rupees.Note: 1 Dollar = 83.3339 RupeeInput format :The input consists of a double value, dollar, representing the amount in dollars to be converted.Output format :The output displays the dollar amount with two decimal places followed by "Dollar = ", and the corresponding rupee amount with two decimal places followed by "Rupees".Refer to the sample output for the formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:1.0 ≤ dollar ≤ 1000.0Sample test cases :Input 1 :1.0Output 1 :1.00 Dollar = 83.33 RupeesInput 2 :158.8Output 2 :158.80 Dollar = 13233.42 RupeesInput 3 :1000.0Output 3 :1000.00 Dollar = 83333.90 RupeesCode Size : 1024 kbNote :The program will be evaluated only after the “Submit Code” is clicked.Extra spaces and new line characters in the program output will result in the failure of the test case.
Single File Programming QuestionProblem StatementMaria loves shopping and is curious to know the total cost of her favorite items. She intends to purchase t items, each priced at p rupees, with a progressive increase of 5 rupees for every subsequent item.Write a program that takes the price of one item (p) and the number of items (t) as input, calculates the total cost using the formula (t/2) * (2p + (t-1) * 5), and displays the result.Input format :The first line of input consists of a float value p, representing the price of an item.The second line of input consists of an integer t, representing the number of items.Output format :The output displays "Rs. " followed by a float value, representing the total cost in rupees, rounded off to two decimal places.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the test cases fall under the following constraints:10.0 ≤ p ≤ 1000.01 ≤ t ≤ 100Sample test cases :Input 1 :10.03Output 1 :Rs. 45.00Input 2 :720.056Output 2 :Rs. 48020.00
Single File Programming QuestionProblem StatementA person is planning a trip abroad and wants to convert their local currency to the destination currency. Write a program for this where the exchange rate is fixed at 1.18. The program should take an amount in one currency as input, convert it to another currency using the exchange rate, and then output the converted amount rounded to two decimal places. Input format :The input consists of double value n, representing the currency.Output format :The output prints the converted currency in double value with two decimal places.Refer to the sample output for formatting specifications.Code constraints :In this scenario, the given test cases fall under the following constraints:1.00 ≤ n ≤ 5000.00Sample test cases :Input 1 :1.00Output 1 :1.18Input 2 :5000.00Output 2 :5900.00Input 3 :2568.95Output 3 :3031.36
Assignment operatorsYou want to withdraw some money from your bank account.The program takes two numbers as input, your account balance and the amount you want to withdraw, and assigns them to corresponding "balance" and "withdraw" variables.TaskCalculate and output the remaining balance after the withdrawal.Sample Input4500009000Sample Output441000ExplanationThe first two lines of the given code declare the balance and the withdraw variables, whose values will be automatically taken as input and will be used in test cases. This means that your solution will be tested with different values of those variables.Don't change that part of the code and treat it as a usual variable.Use the -= shorthand for easier calculation.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.