HS08TEST - Editorial

#include
#include<stdio.h>
#include
using namespace std;
int main()
{
int x;
float y;
cin>>x;
cout<<"\t";
cin>>y;
if(x%5==0 && y-(x+0.5)>0)
{
cout<<"\n";
cout<<setprecision(2)<<y-(x+0.5)
}
else
{
cout<<"\n";
cout<<setprecison(2)<<y;

}
return 0;
}#include
#include<stdio.h>
#include
using namespace std;
int main()
{
int x;
float y;
cin>>x;
cout<<" “;
cin>>y;
if(x%5==0 && y-(x+0.5)>0)
{
cout<<”\n"<<setprecision(4)<<y-(x+0.5);
}
else
{
cout<<"\n"<<setprecision(4)<<y;
}
return 0;
}

Can someone tell me why my code worked with printf and not cout and setprecision??

X = int(input())
Y = float(input())

if X>0 and X<=2000 and Y>=0 and Y<=2000:
    if X<=Y and X%5==0:
        Y = float(Y - X - 0.50)
        print("%.2f" % Y)
    else:
        print("%.2f" % Y)

I say Runtime error but why?

@noswear

input contains only one line,but you are taking 2 lines of input and hence you are getting runtime error.Take single line of input and split them.Then your code will work fine.

Hey i m getting wrong answer. Can pls any1 pls me with this ?

code -

import java.util.*;
import java.util.Scanner;

class Dcoder
{
public static void main(String args[])
{

   double X, Y;
   Scanner scan = new Scanner(System.in);
 
   Y = scan.nextDouble();
   
   X = scan.nextDouble();
   
   X= X+(float)0.50;


   if( X<Y && X%5 == 0){
   	Y = Y-X;
   	System.out.println(Y);
      	}
   else{
   	System.out.println(Y);
   }	 
}

}

my code in java is not working please help me.

import java.util.*;

class sol{

public static void main(String []arg){

Scanner sc=new Scanner(System.in);

float w=sc.nextFloat();

float a=sc.nextFloat();

if(w%5!=0 || w>(a+0.5)){

System.out.printf("%.2f\n",a);

}
else{

System.out.printf("%.2f\n",a-w-0.5);
}
}

}

double b,a;
cin>>a>>b;
if((int)a%5 == 0 && a < b && a > 0)
cout<<fixed<<setprecision(2)<<b - a - 0.50<<endl;
else
cout<<fixed<<setprecision(2)<<b<<endl;

please tell me ,what’s the problem ???
i get 4 times WA

#include
#include
using namespace std;
int main() {
int x;
float y,a;
cin >>x >>y;
if(x%5==0&&y>x){
a = y-x-0.50;
cout<<setprecision(2)<<fixed<<a;
}
else if(x%5==0 && x>y) {
cout<<setprecision(2)<<fixed<<y;
}
else{
cout<<setprecision(2)<<fixed<<y;
}
return 0;
}

#include<stdio.h>
void main()
{
int n;float f;
scanf("%d",&n);
scanf("%f",&f);
if(n>2000||f>2000.00)
{
return ;
}
else if(n%5==0&&n<f)
{
printf("%.2f",(float)f-(n+0.5));
}
else if(n%5==0&&n>f)
{
printf("%.2f",(float)f);
}
else if(n%5!=0)
{
printf(".2f",(float)f); } else if(n>f) { printf(".2f",(float)f);
}
}

what is wrong in this code?It is working fine in my pc but shows run time error during submission

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

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

}