AF
HomeTagSubmit NotesAsk AnythingLoginSubscribe Us
AF
1. Feel Free to ask and submit anything on Anyforum.in and get satisfactory answer
2. Registration is not compulsory, you can directly login via google or facebook
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 352
programming x 168
Posted On : 2017-01-25 06:23:27.0
profile Raksha - anyforum.in Raksha
2510
up-rate
4
down-rate

Answers


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
profile Rishi Kumar - anyforum.in Rishi Kumar
523188221961
Reply This Thread
up-rate
-1
down-rate

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
profile Raksha - anyforum.in Raksha
2510
Reply This Thread
up-rate
1
down-rate
Comments
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;
}
}
profile Rishi Kumar - anyforum.in Rishi Kumar
523  1882  21961
Posted On :2017-01-29 23:25:20.0
Leave a Comment
It is showing error... where to include public static void main(String[] args)
profile Raksha - anyforum.in Raksha
25  1  0
Posted On :2017-02-05 10:24:36.0
Leave a Comment
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;
}
}
profile Rishi Kumar - anyforum.in Rishi Kumar
523  1882  21961
Posted On :2017-02-07 00:10:14.0
Leave a Comment



Post Answer
Please Login First to Post Answer: Login login with facebook - anyforum.in