You are not logged in. Please login at www.codechef.com to post your questions!

×

HS08TEST - Editorial

PROBLEM LINK:

Practice

Author: ADMIN

Editorialist: SUSHANT AGARWAL

DIFFICULTY:

CAKEWALK

PREREQUISITES:

Basic looping,Basic Input/Output,Data Types

EXPLANATION:

Please refer to the sample solution given by editorialist.

EDITORIALIST'S SOLUTION:

Editorialist's solution can be found here.

This question is marked "community wiki".

asked 17 Dec '14, 14:40

sushant96's gravatar image

0★sushant96
21368
accept rate: 0%

closed 16 Jun '17, 19:00

skbly7's gravatar image

2★skbly7
1.9k91724

3

Editorialist solution is wrong withdraw%5==0&&balance>=withdraw+0.5 is the correct condition..

(22 Jan '15, 15:28) aashish_iitm2★

Hey @skbly7 -

  1. Q isnt properly closed, common bug when we click on close button twice.

  2. Why close an editorial? People usually come to editorials to ask doubt, so why close it???

(16 Jun '17, 20:54) vijju123 ♦6★

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.

(06 Sep, 03:21) joffan4★

12345 ... 10next »

withdraw+0.50>bankamount This condition is necessary when in input is : 120 120.00 output should be : 120.00 not : -0.50

link
This answer is marked "community wiki".

answered 16 Mar '17, 00:07

simmiglani's gravatar image

2★simmiglani
1
accept rate: 0%

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?

link

answered 04 Jun '17, 17:20

vani_24's gravatar image

0★vani_24
211
accept rate: 0%

Follow standard input/output format. Don't print those "enter amt ... " etc.

(04 Jun '17, 20:10) ayan_nitd5★

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.

(05 Jun '17, 16:26) vani_240★
#include <stdio.h>
main ()
{
 int x,y,e;
 float z;
 printf ("enter the pooja's account balance  ");
 scanf ("%d",&y);
 printf ("enter the amount you want to withdraw");
 scanf ("%d",&x);
 e=y%5;
 if ((0<=x<=2000) && (0<=y<=2000) && (x<y)&& (e=0))
 {
 z=y-x;
 printf ("the current account balance is %.2f",z);
 }
 else if (e!=0)
 {
     printf ("%.2f",(float)y);
 }
 else if (x>y)
 {
     printf ("%.2f",(float)y);
 }
 else
    exit (0);
}
link
This answer is marked "community wiki".

answered 15 Jan '15, 16:49

zyloc's gravatar image

1★zyloc
211
accept rate: 0%

edited 22 Jan '15, 18:56

damn_me's gravatar image

3★damn_me
2.6k21336

2

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!!

(22 Jan '15, 18:58) damn_me3★
Answer is hidden as author is suspended. Click here to view.

answered 24 Jun '15, 15:23

lionelanand10's gravatar image

2★lionelanand10
(suspended)
accept rate: 0%

include<stdio.h>

int main() { int x; float y , z; scanf("%d",&x); scanf("%f",&y); if(y>=0 && y<=2000); { if(x!=0 && x%5==0 && x<y) printf("%f",y-x-0.50);="" }="" if(x%5!="0" ||="" x="">y ) printf("%f",y); if(x==0 || x==y) printf("%f",y); return 0; } what is wrong with the code any one can run it on code blocks and can check it i have to copy other's code to proceed further

link
This answer is marked "community wiki".

answered 25 Dec '16, 01:03

albert_012's gravatar image

2★albert_012
-15
accept rate: 0%

wikified 25 Dec '16, 01:07

rageking try corner cases

link

answered 31 Jan, 13:54

zizx's gravatar image

1★zizx
515
accept rate: 0%

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

link

answered 31 Jan, 13:55

zizx's gravatar image

1★zizx
515
accept rate: 0%

include<stdio.h>

int main() { unsigned int x; //amount withdrawn float y; //bank balance scanf("%d%f", &x,&y); if(x>0&&x<=2000&&y>0&&y<=2000) {

    if(x>y&&x%5==0)
        printf("%0.2f", y);
    else if(x%5==0)
    {
        y=(y-x)-0.5;
        printf("%0.2f", y);
    }
    else
        printf("%0.2f", y);
}

getchar(); return 0; }

link
This answer is marked "community wiki".

answered 24 Feb '15, 01:08

striker22's gravatar image

1★striker22
1
accept rate: 0%

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

(24 Feb '15, 07:35) drgn_hart2★

include<stdio.h>

main()

{

int i;
float k,j;
scanf("%d",&i);
scanf("%f",&j);
if (0<i&&i<=2000 && 0<=j&&j<=2000)
{

if (i%5!=0||i>j)
k=j;
else 
k=j-0.50-i;
printf("%.2f",k);
}
return 0;

}

can anyone tell why this is wrong??

link

answered 09 Mar '15, 17:11

nawanihappy's gravatar image

0★nawanihappy
1
accept rate: 0%

edited 09 Mar '15, 17:13

#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 this?

link

answered 10 Mar '15, 15:38

sunnybhasin's gravatar image

0★sunnybhasin
1
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,533
×163
×45
×43

question asked: 17 Dec '14, 14:40

question was seen: 16,299 times

last updated: 27 Sep, 19:12