Are you sure that your output is upto 2nd decimal place @anany_097?
because 120.000 is NOT 120.00 and hence would be flagged wrong.
Also, e is the money to be withdrawn. make sure that e is a multiple of 5.
Are you sure that your output is upto 2nd decimal place @anany_097?
because 120.000 is NOT 120.00 and hence would be flagged wrong.
Also, e is the money to be withdrawn. make sure that e is a multiple of 5.
Can anyone tell me that why the Codechef mark it as a wrong answer?
#include <stdio.h>
int main(void) {
int x; //amount to withdraw
float y; //initial balance
scanf("%d %f",&x,&y);
if((x>0) && (x<=2000) && (y>=0) && (y<=2000))
{
if((x<y) && (x%5 ) == 0)
printf("%.2f",y-x-0.50);
else
printf("%.2f",y);
}
return 0;
}
withdraw**+0.50**>bankamount
This condition is necessary when in input is :
120 120.00
output should be :
120.00
not :
-0.50
#include <stdio.h>
int main(void)
{
int x=0;
float y=0;
scanf("%d",&x);
scanf("%f", &y);
if((x%5==0)&&(x<y))
{
y = y - x - 0.50;
printf("%.2f", y);
}
else
printf("%.2f", y);
return 0;
}
how is this a wrong answer?
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
#include
#include
using namespace std;
int main()
{
int x;
float output,y;
std::cin >> x >> y;
if((x>2000 || x <=0) || (y > 2000 || y < 0))
{
return 0;
}
if(x>y)
{
std::cout << fixed <<std::setprecision(2) << y;
}
else
if(x % 5 != 0)
{
std::cout << fixed << std::setprecision(2) << y;
}
else
{
output = y - x - 0.50;
std::cout << fixed << std::setprecision(2) << output;
}
return 0;
}
WHAT IS WRONG IN THIS CODE???
#include<stdio.h>
main()
{
int x,y,p;float z;
printf(âenter the initial account balanceâ);scanf("%d",&y);printf(âenter the amount you want to withdrawâ);scanf("%d",&x);
p=x%5;
if((0<=x<=2000)&&(0<=y<=2000)&&(x<y)&&(p==0))
{z=y-x-0.5;printf(âthe current account balance is .2f",z);}
else
printf("".2fâ,(float)y);
}
#include<stdio.h>
main()
{
int x,y,p;float z;
printf(âenter the initial account balanceâ);scanf("%d",&y);printf(âenter the amount you want to withdrawâ);scanf("%d",&x);
p=x%5;
if((0<=x<=2000)&&(0<=y<=2000)&&(x<y)&&(p==0))
{z=y-x-0.5;printf(âthe current account balance is .2f",z);}
else
printf("".2fâ,(float)y);
}
using namespace std;
int main() {
// your code goes here
double bal;
int wid;
cin>>wid;
cin>>bal;
cout.precision(2);
cout.setf(ios::showpoint);
if(wid%5!=0||wid>bal-0.50)
cout<<fixed<<bal;
else
{
cout<<fixed<<bal-wid-0.50;
}
return 0;
}
package main
import (
âstrconvâ
âfmtâ
âmathâ
)
func main(){
fmt.Print("Enter Amount : ")
var amount string
fmt.Scanln(&amount)
var ar float64
i, _ := strconv.ParseFloat(amount,64)
h := math.Mod(i, 5.0)
if i <= 2000{
if h != 0 {
fmt.Print(ar)
}
if h == 0{
var va float64
va = ar - i - 0.50
fmt.Print(âBalance :â)
fmt.Print(va)
}
}
if i > 2000 {
fmt.Print(ar)
}
}
I wrote this code in go ,it works fine in my laptop ,but not in codechef. Is there any problem with it?
Donât print any statements,printing only answer is enough
import java.util.Scanner;
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 amout in account");
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);
}
}
}
}
whats wrong with this code?
Follow standard input/output format. Donât print those "enter amt ⌠" etc.
#include<stdio.h>
int main()
{
float y;
int x;
scanf("%d",&x);
scanf("f",&y);
if(x>0&&x<=2000&&y>=0&&y<=2000)
{
if(x>=y)
printf(".2f",y);
else if(x%5!=0)
printf(".2f",y);
else
printf(".2f",y-x-0.5);
}
return 0;
}
whatâs wrong with this??
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.
import java.io.*;
class HS08TEST
{ public static void main(String args[])throws IOException
{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=br.readLine();
int x=Integer.parseInt(s.substring(0,s.indexOf(â â)));
double y=Double.parseDouble(s.substring(s.indexOf(â â)+1));
if( y-x-0.5<x+0.5 || x%5!=0)
{ System.out.println(s.substring(s.indexOf(â â)+1));
}
else
{ double result=y-x-0.50;
String st=result+"";
if(Integer.parseInt(st.substring(st.indexOf(â.â)+1))>9)
{ System.out.println(st);
}
else
{ System.out.println((st+â0â));
}
}
}
}
what is wrong with this code? it is working perfectly in BlueJ but showing WA in CodeChef compiler
Hey @skbly7 -
Q isnt properly closed, common bug when we click on close button twice.
Why close an editorial? People usually come to editorials to ask doubt, so why close it???
import java.util.Scanner;
import java.io.*;
class Codechef1
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println(âAmount of cash you want to withdrawâ);
int x = sc.nextInt();
if(0<x && x<=2000)
{
System.out.println(âYour intial account balanceâ);
double y = sc.nextDouble();
if(0<y && y<=2000)
{
if(x%5==0 && x<=y)
{
double rem = y-x-0.50;
System.out.println(""+rem);
}
else
{
System.out.println(""+y);
}
}
}
}
}
WHATâS Wrong with this code?
main()
{
int x;
double y=0.00,z=0.50;
cin>>x>>y;
while(x>0 && x<=2000 && y>=0 && y<=2000)
{
if(x%5==0 && x<y)
{
z= (y-x)-z;
cout<<setprecision(2)<<fixed<<z;
break;
}
else
cout<<setprecision(2)<<fixed<<y;
break;
}
return 0;
}
Why is this wrong?
#include<stdio.h>
int main()
{
int a,b,temp=0;
float c,d;
scanf("%d%f",&a,&c);
if(a%5==0 && a<=2000 && c<=2000.00)
{
b=1;
if(a<c)
{
temp=1;
}
}
else
{
b=0;
}
if(b==1 && temp==1)
{
printf("\n Successful Transaction");
c=c-0.50;
c=c-a;
printf("\n Available Balance is %0.2f",c);
}
else if(b==0)
{
printf("\n Invalid transaction or check your balance, Please enter amnount in multiple of 5");
printf("\n Available Balance is %0.2f",c);
}
else
{
printf("\n Insuficient fund");
printf("\n Available Balance is %0.2f",c);
}
}
whats wrong in this program