AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
3. Our Experts are looking for yours ?.

corejava-programming: Bank of Ignite ATM

 You would like to withdraw Rs. X from an ATM. The ATM stores only Rs. 100 notes and thus accepts the transaction if X is a multiple of 100. Ofcourse, your account balance must have enough cash to perform the withdrawal transaction (including bank charges). For each successful withdrawal the bank charges Rs. 5 Calculate your account balance after an attempted transaction. Input Positive integer 0 < X <= 50000 - the amount of cash which you wish to withdraw. Non-negative number 0<= Y <= 500000 with two digits of precision - your initial account balance. Output Output the account balance after the attempted transaction, given as a number with two digits of precision. If there is not enough money in the account to complete the transaction, output the current bank balance. Example - Successful Transaction Input: 20000 50000 Output: 29995 Example - Incorrect Withdrawal Amount (not multiple of 100) Input: 4550 20000 Output: 20000 Example - Insufficient Funds Input: 30000 25000 Output: 25000 corejava x 353programming x 168 Posted On : 2017-01-25 06:23:27.0 Raksha 2510 4

 import java.util.Scanner; public class IgniteATM { public static void main(String[] args) { Scanner input =new Scanner(System.in); int x=input.nextInt(); int y=input.nextInt(); if(0 < x && x <= 50000){ if(x%100==0){ if(0<= y && y <= 500000){ if(y>=x+5){ System.out.println(y-(x+5)); }else{ System.out.println(y); } }else{ System.out.println("Invalid input"); } }else{ System.out.println(y); } }else{ System.out.println("Invalid input"); } } } Posted On : 2017-01-27 17:08:10 Satisfied : 4 Yes  1 No Rishi Kumar 523188222697Reply This Thread -1

 public class Atm { public int withdrawal(int input1, int input2){ /*Do not change the method signature or class name Click submit to check your code */ int output=-1; return output; } } Posted On : 2017-01-29 12:07:29 Satisfied : 0 Yes  0 No 1
public class Atm {
public int withdrawal(int input1, int input2){
int output=-1;
int transactionCharge=5;
if(0 < input1 && input1 <= 50000){
if(input1%100==0){
if(0<= input2 && input2 <= 500000){
if(input2>=input1+5){
output=input2-(input1+transactionCharge);
}else{
output=input2;
}
}
}else{
output=input2;
}
}
return output;
}
}
Rishi Kumar
523  1882  22697
Posted On :2017-01-29 23:25:20.0
It is showing error... where to include public static void main(String[] args)
Raksha
25  1  0
Posted On :2017-02-05 10:24:36.0
Hi Raksha,

FYI..

import java.util.Scanner;

public class Atm {

public static void main(String[] args) {
Atm atm=new Atm();
Scanner input=new Scanner(System.in);
System.out.println(atm.withdrawal(input.nextInt(), input.nextInt()));
}

public int withdrawal(int input1, int input2){
int output=-1;
int transactionCharge=5;
if(0 < input1 && input1 <= 50000){
if(input1%100==0){
if(0<= input2 && input2 <= 500000){
if(input2>=input1+5){
output=input2-(input1+transactionCharge);
}else{
output=input2;
}
}
}else{
output=input2;
}
}
return output;
}
}
Rishi Kumar
523  1882  22697
Posted On :2017-02-07 00:10:14.0