-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDay05_prob2.java
More file actions
66 lines (52 loc) · 1.81 KB
/
Day05_prob2.java
File metadata and controls
66 lines (52 loc) · 1.81 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
/*
Shruti is running a jewellery shop. She got calls from her customers to know the current price of silver and gold in different weights. Write a program to help Shruti to calculate price in the different weights when Shruti knows the weight of 1 Kg. Silver and 10 gm. Gold.
Input Format
First line will contain a number representing 1Kg. Silver price.
Second line will contain a number representing 10gm. Gold Price.
Third Line will contain a String value Silver/Gold representing user input to know the price.
Fourth line will contain weight of silver/gold in grams for which user want price.
Constraints
Price cannot be -ve and maximum can be 1000000.
Weights entered by user can be between 0.01 gm to 1000 gms.
Output Format
One number representing value of gold/silver asked by user for a particular weight.
Sample Input 0
60000
54256.25
Silver
400
Sample Output 0
24000
Sample Input 1
10000
7000
Gold
0.001
Sample Output 1
Invalid Input
*/
// 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 price_silver=sc.nextDouble();
double price_gold=sc.nextDouble();
String user=sc.next();
double grams=sc.nextDouble();
System.out.println(user);
if(price_silver<0 || price_silver>1000000 || price_gold<0 || price_gold>1000000 || grams<0.01 || grams>1000){
System.out.println("Invalid Input");
}
else{
if(user=="Silver"){
System.out.println((int)(price_silver*grams/1000));
}
else{
System.out.println((int)(price_gold*grams/10));
}
}
}
}