def atm(num1, num2):
y = int(num1)
z = float(num2)
lastdig = int(repr(y)[-1])
if y>z or y==z:
return(format(z, ‘.2f’))
else:
if lastdig == 0 or lastdig==5:
m = float(z-y-0.50)
return(format(m, ‘.2f’))
elif lastdig != 0 or lastdig != 5:
return(format(z, '.2f'))
I wrote this Python code and when I submit it, it states that it is wrong but whenever I run it on my computer or on the codechef IDLE it works very well
/* 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 sc=new Scanner(System.in);
double a_bal = 0.50; //bank transaction charge
long x=sc.nextLong();
double b=sc.nextDouble();
if((x%5==0) && b-a_bal>=x){
double remaining=b-x-a_bal; // here b-a_bal is mentioned because balance should be greater than 0.50 for withdrawl
System.out.println(String.format("%.2f", remaining));
}
else{
System.out.println(String.format("%.2f", b));
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CodeChef_ATM
{
class Program
{
static void Main(string[] args)
{
/* Made by Stefan Stojanovic [Alisp]
using .NET Visual Studio Community 2019 16.8.1*/
// User input for bank account and withdrawal amount
Console.WriteLine("Input how much money you have in the bank acount and how much you would like to withdraw. The Bank takes 0.5$ as tax.");
Console.WriteLine("Example: '200' '99'");
Console.Write("(Account)(Withdrawal): ");
string[] userInput = Console.ReadLine().Split(' ');
// Current account balance.
double trueaccount = Convert.ToDouble(userInput[0]);
double accounttracker = trueaccount;
// Withdrawal amount.
double truewithdraw = Convert.ToDouble(userInput[1]);
// Check if multiple of 5.
if (truewithdraw % 5 == 0)
{
Console.WriteLine("Withdrawal must me a multiple of 5. Example: 54,36,29...");
Console.WriteLine("Try Again.");
Console.ReadLine();
return;
}
// Check if there is enough available money.
if (truewithdraw + 0.5 > trueaccount)
{
Console.WriteLine("You can't withdraw more than available money from the account.");
Console.WriteLine("Try Again.");
Console.ReadLine();
return;
}
// Calculating the withdrawal.
trueaccount -= truewithdraw;
trueaccount -= 0.50;
// Result.
Console.WriteLine($"The amount of money you had in the account: {accounttracker}$");
Console.WriteLine($"The amount of money you have currently: {trueaccount}$");
// End.
Console.ReadLine();
}
}
}