HS08TEST - Editorial

#include<stdio.h>

int main()
{
int wb;
float ib,fb;
printf(“Enter withdrawl balance and intial balance repectively\n”);
scanf("%f%d",&wb,&ib);
if (wb%5==0 && wb>0 && wb<=2000 && ib>=0 && ib<=2000)
{
fb=ib-wb-.50;
printf("\nFinal balance=%.2f",fb);

}
else if(wb%5!=0 && wb>0 && wb<=2000 && ib>=0 && ib<=2000)
{
	printf("\nFinal balance=%.2f",ib);
	
 } 
 else if(ib<wb && wb>0 && wb<=2000 && ib>=0 && ib<=2000 )
 {
 	printf("\nInsufficient fund=%.2f ",ib);
 }
 else
 printf("\nInvalid entries");
 
 return 0;

}

#include
#include
using namespace std;
int main()
{int x;
float y;
cout<<“enter amount to be withdrawn (0<amount<2000)”;
cin>>x;
cout<<“enter actual balance of account(0<bal<2000)”;
cin>>y;
if(x<0 && x>=2000 && y<=0 && y>=2000)
{ cout<<“enter correct value”;}
else if (x%5==0 && x<=y)
{
x=float(x);
y=y-x-0.5;
}
else if(x>y)
cout<<“insufficient fund \n”;
cout<<fixed<<setprecision(2)<<y;
return 0;}
whats wrong in this prgrm

#include
#include
using namespace std;
int main()
{int x;
float y;
cout<<“enter amount to be withdrawn (0<amount<2000)”;
cin>>x;
cout<<“enter actual balance of account(0<bal<2000)”;
cin>>y;
if(x<0 && x>=2000 && y<=0 && y>=2000)
{ cout<<“enter correct value”;}
else if (x%5==0 && x<=y)
{
x=float(x);
y=y-x-0.5;
}
else if(x>y)
cout<<“insufficient fund \n”;
cout<<fixed<<setprecision(2)<<y;
return 0;}
whats wrong in this prgrm

#include
#include
using namespace std;

int main()
{
int i;
float j,k;
cin >> i >> j;
cout<<fixed;
if((0<i && i<=2000) && (0<=j && j<=2000)){
if ((i<j) && (i%5==0))
{

cout<<setprecision(2)<<j-i-0.5;

}
else if((i==j) && (i%5 == 0))
{
cout << setprecision(2)<< -0.5;
}
else cout <<setprecision(2)<< j;
}

return 0;
}
// whats the probel in this

coded this in Python but it is giving me Runtime Error(NZEC). Can you please tell me what is the problem with this?

trans = float(input())

bal= float(input())

if trans%5 == 0 and bal >=(trans+0.50) :
print ( bal - trans -0.50)

else:
print (bal)

1 Like

#include
using namespace std;
int main()
{
float n=0,m; // wishes to withdraw 1st input = n
cin>>n;
cin>>m;
if(0<n&&n<=2000 && 0<m&&m<=2000)
{

if(m>n)
{
if((int)n%5==0)
{
    float sum= 0;
    sum = m - n - 0.5;
    cout<< sum;
}
else
{
    cout<<m;
}
}
}
else
{
    cout<<m;
}
return 0;

}
whats wrong this code?

import java.util.*;

public class Main

  {

  public static void main(String[] args) 
  {

	Scanner console = new Scanner(System.in);
	System.out.printf("\t\tInput:\n\t\t");
	int x= console.nextInt();
	double y=console.nextDouble();
	if(x%5==0){
		if (y-x-0.5>0){
			y=y-x-0.5;
			output(y);
		}
		else{
			output(y);
			System.out.printf("\n\t\tInsufficient Fund");
		}
	}
	else{
		output(y);
		System.out.printf("\n\t\tnot multiplier of 5");
	} 
}

public static void output(double y){
	System.out.printf("\t\tOutput:\n");
	System.out.printf("\t\t%.2f",y);
}

}

Wrong answer …any1 tell me why …it runs great in my laptop

wd_amt,in_amt = list(map(float, input().split()))

this is how you put the input in python

and for output

print("{0:.2f}".format(output))

Can you please tell me what is wrong in below code

Blockquote

    class CodeChef
      {
    public static void main(String[] args) throws java.lang.Exception
    {	
	int wd = 0;
	Float bal;
	 
	Scanner scan= new Scanner(System.in);
//	wd = scan.nextInt();
//	bal = scan.nextFloat();
	
	List<BigDecimal> list = new ArrayList<BigDecimal>();
	scan.useDelimiter("\\s");
	while (scan.hasNextFloat())
		list.add(scan.nextBigDecimal());
	
	MathContext mc = new MathContext(4, RoundingMode.HALF_DOWN);
	BigDecimal [] nums = (BigDecimal[]) list.toArray(new BigDecimal[0]);
	BigDecimal reaminingAmt=nums[1].subtract(nums[0], mc);
	BigDecimal dedAmt=new BigDecimal(0.5);
	int ans = reaminingAmt.subtract(dedAmt,mc).setScale(2, RoundingMode.HALF_DOWN).intValue();
	
//	double ans=bal - wd-0.5;
	
	if(ans > 0 && wd%5==0){
		System.out.print(ans);
	}else{
		System.out.print(nums[1]);
	}
	
}
}

amount=float(input("enter amount to be withdrawn "))
balance=float(input(“enter balance amount”))
if(amount+0.5<balance):
if(amount>0):
if(amount%5==0):
balance=balance-amount-0.50
print (balance)
else:
print(“2000.00”)
else:
print(“2000.00”)

#whats wrong with this code

My code is getting the NZEC error please help me my code is
/* package codechef; // don’t place package name! */

import java.util.;
import java.io.
;

class Codechef
{
public static void main (String[] args) throws IOException
{
try{
Scanner input = new Scanner(System.in);
System.out.println(“Enter initial acc balance”);
float acc = input.nextFloat();
System.out.println(“Enter the amount to withdraw”);
int wd = input.nextInt();
if(wd%5==0)
{
if(wd<=acc)
{

	        double nacc = (acc - wd) - 0.50;
	        System.out.println("Account balance after deduction is "+nacc);
	    }
	}
	else
	{
	    System.out.println("Account balance is "+acc);
	}
	}catch (Exception e){
	return;}
}

}

#include

#include<math.h>

#include

using namespace std;

int main()

{

int withdraw;

float balance;

cin>>withdraw;

cin>>balance;

if(withdraw%5==0)
{

if(balance>=withdraw-0.50)

{

cout<<fixed<<setprecision(2)<<balance-withdraw-0.50<<endl;

}

else

{

cout<<fixed<<setprecision(2)<<balance<<endl;

}

}

else
{

cout<<fixed<<setprecision(2)<<balance<<endl;

}

return 0;

}

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

}