-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay15_prob1.java
More file actions
61 lines (49 loc) · 1.83 KB
/
Day15_prob1.java
File metadata and controls
61 lines (49 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
Peter logins into his banking application to perform certain transaction. Initially he is asked to enter his present balance. Then he is shown three options to choose from, where he is asked to choose 1 for withdrawal and 2 for deposit and 3 to check the balance. On choosing 1, he is prompted to enter amount to be withdrawn. In case if the amount entered is greater than his present balance, "error" should be displayed, the account balance should be updated otherwise. On choosing 2, he is prompted to enter amount to be deposited and the account balance should be updated. Choosing 3 should display the balance. Choosing any other option should display "error".
Input Format
10000.20
2
200.50
Constraints
The balance and amount are to be taken as float type numbers. The output displayed too is a floating point number.
Output Format
10200.70
Sample Input 0
20000.20
1
100.00
Sample Output 0
19900.20
*/
// kirtan jain
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble();
int b = sc.nextInt();
double c = sc.nextDouble();
if(b<1 || b>3){
System.out.println("error");
}
else{
if(b==1 && c>a){
System.out.println("error");
}
else if (b==1 &&c<a){
System.out.println(String.format("%.2f", a-c));
}
else if(b==2){
System.out.println(String.format("%.2f", a+c));
}
else if(b==3){
System.out.print(a);
}
else{
System.out.println("error");
}
}
}
}