What is the error?
x=int(input("Enter the amount in multiple of 5 which is to be withdrawed: "))
y=float(input("Enter the account balance: "))
if x>y:
print(“The transaction is not successfull. You do not have required balance”)
print("The balance is: ", end=‘’)
print(round(y,2))
elif x%5==0 and x0 and y>0:
balance=y-x-0.5
print("Your Transaction is successful. The balance after the transaction is: ", end=‘’)
print(round(balance,2))
else:
print(“The transaction is not successfull. Enter the required value in multiple of 5”)
print("The balance is: ", end=‘’)
print(round(y,2))
I am facing Run Time error
Not sure about the language as I don’t know anything about python.
I have solved it in C++.
I think you should learn about I/O (input/output) in competitive programming or in other online submissions.
You have to print exactly what problems ask you to, as you are printing a lot of the texts like
_"Enter the amount in multiple of 5 which is to be withdrawed:"
you must have been taught this in school while you learned about programming but here it does not work like that.
Furthermore, I do not have knowledge about python but I tried compiling your code, It shows an error in line 4. I hope it helps.
I am providing my code for reference if you understand C++, this might help.
void solve()
{
const double rate = 0.50;
int x = 0;
double y = 0;
cin >> x >> y;
if ((x + rate) <= y && x % 5 == 0) //sucessful transaction
{
y = y - (x + rate);
cout << fixed << setprecision(2) << y;
}
else
{
cout << fixed << setprecision(2) << (double)y;
}
}
You Can Check Out My Solution: CodeChef: Practical coding for everyone
And Recode It In C++
2) Just Understand The Concept You Will Be Able To Solve
3) And Read Question Again And Again
4) You Can Use Link Also I Have Also Provided The Solution Here
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scin = new Scanner(System.in);
int withdraw = scin.nextInt();
double balance = scin.nextDouble();
if(withdraw+0.50<=balance&&withdraw%5==0){
balance=balance-withdraw-0.50;
}
System.out.println(balance);
}
}