HS08TEST - Editorial

#include<stdio.h>
int main()

{

int x;

float y;

scanf("%d %f",&x,&y);

if((x%5==0)&&(x<y))

{

    printf("%.2f",(y-x-0.5));

}

else

{

    printf("%.2f",y);

}

return 0;

}

what’s wrong in this code ?

`import java.util.Scanner;
class ATM {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
double x=sc.nextDouble();
double y=sc.nextDouble();
if(x%5==0&&x<(y+0.5))
{ y=y-x-0.5;
System.out.println(y);
}
else
System.out.println(y);

}

}
`
What’s wrong in this code?

#include<stdio.h>

    int main(void)
    {
      int widrlAmt;
  float bankCharge = 0.5;
  float initAmt, finAmt;

  scanf("%d %f",&widrlAmt, &initAmt);

  finAmt = initAmt - widrlAmt;

  if(widrlAmt%5==0 && finAmt > 0 && 0<widrlAmt<2000 && 0<initAmt<2000)
  {
    finAmt -= bankCharge;
    printf("%.2f",finAmt);
  }
          else
        printf("%.2f",initAmt);


       return 0;

    }

Why is it wrong, guys? It’s working all right in CodeBlocks!

rageking try corner cases

1 Like

most of the time inputs are given in such a way that it will look everything is fine but you have to check each and every worst case

1 Like

#include
#include
using namespace std;
int main()
{
int n;
float j;
cin >> n;
cin >> j;
if ( 0<n<=2000 && 0<=j<=2000 && n%5==0 && n<j)
{
j = j -n -0.5;
}
cout << setprecision(2) << fixed <<j;
return 0;
}

please tell me what’s wrong in here?

can any one tell me what is wrong in this code

#include<stdio.h>
main()
{
int a;
float b;
scanf("%d %f \n",&a,&b);
if(a>0&&a<=2000&&b>0&&b<=2000){
if(a%5==0&&b>=a)
printf("%0.2f",b-a-0.5);
else
printf("%0.2f",b);
}
}

Whats wrong with this code??
#include<stdio.h>
int main(){
int x;
float y;
scanf("%d",&x);
scanf("%f",&y);

if(x%5!=0){
   printf("%.2f",y);
} else {
    if(x>y){
        printf("%.2f",y);
    } else {
        printf("%.2f",y-(x+0.50));    
    }      
}
return 0;

}

#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…

Don’t Use new line after displaying the answer.
My Code :-

#include< iostream>
#include< iomanip>
using namespace std;

int main(void)
{

float y,z;int x;
cin>>x>>y;
cout<< fixed<< setprecision(2);
if(x>0 && x<=2000 && y>=0 && y<=2000){
if(x>=y)
cout<< y;
else if(x<=y-0.5)
{
if(x%5==0)
cout<< y-x-0.50;
else
cout<< y;
}
else cout<< y;
}
return 0;
}

Enjoy bro

import java.util.Scanner;
import java.text.DecimalFormat;
public class Main
{
public static void main(String args[])
{
double withdraw,balance;
Scanner sc=new Scanner(System.in);
withdraw=sc.nextDouble();
balance=sc.nextDouble();
if((withdraw%5==0) && (balance>=(withdraw+0.05f)))
System.out.println(new DecimalFormat(“0.00”).format(balance-withdraw-0.05f));
else
System.out.println(new DecimalFormat(“0.00”).format(balance));
}
}

whats wrong here? can anyone please tell me.It is showing Wrong answer here.

#include<stdio.h>
float a,b,c;
int mul(float n);
int main(){
scanf("%f f",&a,&b); if(a<=b){ if(mul(a)){ c = b - a - 0.5; printf(".2f",c);
}

}

if(!mul(a))
printf("%.2f",b);

if(a>b)
    printf("%.2f",b);

}
int mul(float n){
while(n>0.0)
n=n-5.0;

if(n==0.0)
return 1;
else
return 0;

}

can anyone tell, why it is showing wrong answer

What is wrong in this code of mine ?

#include <iomanip>
#include <iostream>

int main()
{
	int x;
	float y;
	std::cin >> x >> y;

	if ((x % 5 == 0) && (x + 0.50 <= y))
	{
		if (0 < x && x <= 2000 && 0 <= y && y <= 2000)
		{
			float j = y - x - 0.50;
			std::cout << std::setprecision(2) << std::fixed << j;
		}
	}
	else
	{
		std::cout << std::setprecision(2) << std::fixed << y;
	}
	return 0;
}

#include
#include
using namespace std;

int main(){
    int witha;
    float balanb;
    cin >> witha;
    cin >> balanb;
    if (witha< balanb){
        if(witha%5==0){
            balanb= balanb-witha-0.5;
            cout << balanb;
        }
        else {
            cout<< balanb;
        }
    }
    else{
        cout << balanb;
    }
    return 0;

}

Whats the error??

How to start with the python. I am begining to the python but i am getting error? so Kindly reply me.

  • #include <stdio.h>
    #include <stdlib.h>

    int main() { int a=0; float
    b=0;

    scanf("%d %f",&a,&b);
    

    if(a<b){
    if(a%5==0){
    printf(".2f\n",(b-a)-0.50); } else{ printf(".2f\n",b);
    } } else{
    printf("%.2f\n",b);
    }
    return 0; }

Why is wrong ?

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.

#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