×

# ATM help getting wrong answer

import java.util.*;

/ * @author Nitish / class Atm {

public static void main(String[] args)
{
// TODO code application logic here
Scanner in=new Scanner(System.in);
int y=in.nextInt();
double balance=in.nextDouble();
//System.out.println(y+" "+balance);
if(y%5==0 && y<balance)
{
balance = balance - y-0.50;
System.out.println(balance);
}
else if(y>=balance)
{
System.out.println(balance);
}
else
{
System.out.println(balance);
}
}


}

what is the problem in ans it's showing me wrong answer??

1111
accept rate: 0%

#include<iostream>

# include<iomanip>

using namespace std; using std::setprecision;

int main() { int a; float b; cin>>a; if(a>0) { cin>>b; cout<<"\t"; if(b>0||b>0) { if(a%5==0) { if(b>a) { cout<<setprecision(2)<<(b-a-0.5); }} else cout<<b; } } return 0; }

(02 Mar '14, 13:30) 0★

 2 There are a couple of bugs in your code (1)Did you read this line carefully in the problem statement :Output the number with two digits of precision.? Your code block System.out.println(balance) is not printing the output in two digit precision. So replace the above line with System.out.printf("%.2f\n",balance);//Prints output in two digits precesions  (2)The if conditions used is wrong  if(y%5==0 && y
 0 Try input 30 30.20  ;-) answered 20 May '12, 17:03 16.9k●49●115●225 accept rate: 11%
 0 import static java.lang.Math.abs; import java.util.Scanner; class Sample1 { public static void main(String[] args){ Scanner scan = new Scanner(System.in); double per = scan.nextDouble(); float s =0.50f; double a=120.00,b; if((per%5)==10){ b = abs(per-120.00); System.out.println(b-(s)); } else{ System.out.println(a); } }  } answered 25 Jan '15, 18:06 0★sri2015 1 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• 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:

×190

question asked: 20 May '12, 14:14

question was seen: 1,330 times

last updated: 25 Jan '15, 18:06