Repository navigation
Expand file tree
/
Copy pathProblems.java
More file actions
102 lines (75 loc) · 3.4 KB
/
Copy pathProblems.java
File metadata and controls
102 lines (75 loc) · 3.4 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package Assignments;
import java.text.DecimalFormat;
import java.util.Scanner;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import static java.lang.System.in;
import static java.lang.System.out;
public class Problems {
private static final DecimalFormat df = new DecimalFormat("0.00");
static Problems problems = new Problems();
public static void main(String[] args) {
problems.getCurrencyInDollars();
// problems.findLargestNumber();
// problems.calculateSimpleInterest();
// problems.computeWithFormula();
}
void getCurrencyInDollars(){
Scanner firstInput = new Scanner(in);
out.println("Enter Rupees: ");
double indianCurrency = firstInput.nextDouble();
double dollarCurrency = indianCurrency/74.42;
out.println("Value in Dollars is "+ df.format (dollarCurrency) + "$");
}
void findLargestNumber(){
Scanner firstInput = new Scanner(in);
out.println("Enter FirstNumber: ");
int firstNo = firstInput.nextInt();
Scanner secondInput = new Scanner(in);
out.println("Enter SecondNumber: ");
int secondNo = secondInput.nextInt();
if (firstNo > secondNo){
out.println(firstNo+" is the Largest Number");
}else {
out.println(secondNo+" is the Largest Number");
}
}
void computeWithFormula(){
Scanner firstInput = new Scanner(in);
out.println("Enter FirstNumber: ");
int firstNumber = firstInput.nextInt();
Scanner secondInput = new Scanner(in);
out.println("Enter SecondNumber: ");
int secondNumber = secondInput.nextInt();
Scanner symbolInput = new Scanner(in);
out.println("Enter Formula(Ex:- +,-,*,/): ");
String symbol = symbolInput.next();
problems.computeTwoNumbers(firstNumber,secondNumber,symbol);
}
void computeTwoNumbers(int firstNumber, int secondNumber, String symbol){
switch (symbol) {
case "+", "addition", "add" -> out.println("Addition of Two Numbers is " + (firstNumber + secondNumber));
case "-", "difference", "minus" -> out.println("Difference of Two Numbers is " + (firstNumber - secondNumber));
case "*", "multiply" -> out.println("Multiplication of Two Numbers is " + (firstNumber * secondNumber));
case "/", "divide" -> out.println("Division of Two Numbers is " + (firstNumber / secondNumber));
default -> out.println("No valid formula Provided!!");
}
// out.println("Addition");
}
void calculateSimpleInterest(){
Scanner input = new Scanner(in);
out.println("Please enter the Principal Amount: ");
int principalAmount = input.nextInt();
out.println("Your Principal Amount is " + principalAmount);
out.println("Please enter your Rate Of Interest: ");
double rateOfInterest = input.nextDouble();
out.println("Your Rate Of Interest is " + rateOfInterest + "%");
out.println("Please enter Time: ");
double timeToCalculate = input.nextDouble();
out.println("Your Time to calculate the Simple Interest " + timeToCalculate + "%");
double calculate = rateOfInterest/100;
out.println(calculate);
double simpleInterest = principalAmount * (1 + (rateOfInterest/100) * (timeToCalculate));
out.println("Your Simple Interest is " + simpleInterest);
}
}