#include
#include
#include<stdlib.h>
using namespace std;
int main()
{
int withdrw;
float max_bal,bal;
cin>>withdrw;
cin>>max_bal;
if((withdrw>0)&&(withdrw<2000)){
if((max_bal>0)&&(max_bal<2000))
{
if(withdrw<max_bal)
{
if(withdrw%5==0){
bal=max_bal-withdrw;
bal=bal-0.50;
cout<<setprecision(2)<<fixed<<bal;
}
else
{
bal=max_bal;
cout<<setprecision(2)<<fixed<<bal;
}
}
else
{
bal=max_bal;
cout<<setprecision(2)<<fixed<<bal;
}
}
}
else
{
exit(0);
}
return 0;
}
what is the problem in this code
#include<stdio.h>
main()
{
int a;
float b;
scanf("%d",&a);
scanf("%f",&b);
if(a>0 && a<=2000 && b>0 && b<=2000)
{
if(a%5==0)
{
if( b>=(a+.50))
{
b=b-a-0.5;
printf("%0.2f",b);
}
if(b< a+.5)
printf("%0.2f",b);
}
else
printf("%0.2f",b);
}
}
What is wrong with this code?
#include<stdio.h>
int main(){
unsigned int amt;
float atm=0.5,bal,rlt;
scanf("%u %f",&amt,&bal);
if((bal+atm)>=amt && amt%5==0 && (0<=bal<=2000) && (0<amt<=2000))
rlt=bal-(amt+atm);
printf("\n%.2f",rlt);
return 0;
}
whats wrong in my code
amnt ,bal = [float(x) for x in input().split()]
print(bal,amnt)
if(amnt > 0 and bal > 0):
if(amnt <= 2000.00 and bal <= 2000.00):
if(amnt+0.5 <= bal and amnt%5 == 0 ):
print(format(bal-amnt-0.50,".2f"))
else:
print(format(bal,".2f"))
whats wrong in this
#include <stdio.h>
#include <stdlib.h>
int main()
{
int transaction;
double balance, response, charges;
balance=2000;
charges=0.50;
printf("\n ATM Machine");
printf("\n------------------");
printf("\n1 Enter the Saving Account");
printf("\n2 Enter the Withdraw money");
printf("\n3 Quit");
printf("\nEnter your Selection:");
scanf("%lf", &response);
if(response==1)
{
printf("\n---------------------");
printf("\nYour current balance: %0.2lf", balance);
printf("\n---------------------");
printf("\nThank you\n");
}
if(response==2)
{
printf("\nEnter amount to withdraw:");
scanf("%d", &transaction);
if((transaction)%5==0)
{
printf("\n---------------------");
printf("\nYour current balance: %0.2lf", balance-transaction-charges);
printf("\n---------------------");
printf("\nThank you for Transaction\n");
}
else
{
printf("\nTransaction Failed");
}
}
if(response==3)
{
printf("\nThank you\n");
}
return 0;
}
Brother, check this code. And tell me what’s wrong on it.
#include <stdio.h>
int main(){
unsigned int amount;
float balance;
scanf ("%d %f",&amount,&balance);
if (balance>=0 && balance <=2000){
if (amount<=(balance-0.5) && amount>0){
if(amount%5==0)
printf("%f",(balance-amount)-0.5);
}
}
return 0;
}
what is the error here? please help me
import java.util.Scanner;
import java.text.DecimalFormat;
class Atm{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
System.out.println("enter amt to be withdrawn:");
double a=s.nextDouble();
System.out.println("enter the current amount in account");
double b=s.nextDouble();
DecimalFormat df=new DecimalFormat("#### 0.00");
if((0<a)&&(0<b)){
if((a<=2000.00)&&(b<=2000.00)){
if(a>b)
System.out.println(df.format(b));
if((a%5)!=0)
System.out.println(df.format(b));
if(((a%5)==0)&&(a==b))
System.out.println(df.format(b-a));
if(((a%5)==0)&&(a<b))
System.out.println(df.format((b-a)-0.50));
}
}
}
}
How to get input in python? Example for python here in forum doesn’t work like:
wd_amt,in_amt = list(map(float, input().split()))
Editorialist solution is wrong withdraw%5==0&&balance>=withdraw+0.5 is the correct condition…
2 Likes
damn_me
January 22, 2015, 6:58pm
97
You dont need those printf() statements you have added in your code. There’s no need of that, go by the I/O format specified in the problem!!
2 Likes
Suppose the input is 120 120.00 then your code gives the output -0.50. Check for that case also. Answer for this case should be 120.00
do paste your code with proper identation.
if((x%5==0)&&(x<y))-This is faulty, as y should be greater than x+0.5, as problem clearly says "enough cash to perform the withdrawal transaction (including bank charges). "
Make changes and get back to me in case of discrepancy
Follow standard input/output format. Don’t print those "enter amt … " etc.
import java.util.Scanner;
class Atm{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
double a=s.nextDouble();
double b=s.nextDouble();
if((0<a)&&(0<b)){
if((a<=2000.0)&&(b<=2000.0)){
if(a>b) System.out.println(b);
if((a%5)!=0) System.out.println(b);
if(((a%5)==0)&&(a==b)) System.out.println(b-a);
if(((a%5)==0)&&(a<b)) System.out.println((b-a)-0.50);
}
}
}
}
now also it shows wrong answer! whats wrong now.? output is coming right in my compiler.
#HERE is your answer… your if condition should be if(x+0.5>y)… to know why go to the link…
#HERE is your answer… your if condition should be if(a%5==0 && b+0.5>=a)… to know why go to the link…
krax4u
July 22, 2018, 9:28pm
106
whats wrong here? can anyone please tell me.It is showing Wrong answer here.
joffan
September 6, 2018, 3:21am
107
Common issues:
The withdrawal amount is an integer . The account balance is not integer (float, real)
To allow withdrawal, the balance must be big enough for the withdrawal AND the fee.
The output must display the non-integer balance.
Also: use the Online IDE for testing (if you don’t have any other way to run programs). Don’t submit your code until it has at least run successfully on the examples provided to give the exact same output as shown in the problem. Preferably also run on some other test data that you make up yourself.
1 Like