-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFurnitureprice.java
More file actions
35 lines (31 loc) · 1.15 KB
/
Copy pathFurnitureprice.java
File metadata and controls
35 lines (31 loc) · 1.15 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
import javax.swing.JOptionPane;
public class Furnitureprice {
public static void main(String[] args) {
// Ask user to input the wood type
String input = JOptionPane.showInputDialog("Enter wood type:\nP for Pine\nO for Oak\nM for Mahogany");
// Convert input to uppercase to handle lowercase entries
if (input != null) {
input = input.toUpperCase();
String message;
// Determine price based on user input
switch (input) {
case "P":
message = "Pine table costs $100";
break;
case "O":
message = "Oak table costs $225";
break;
case "M":
message = "Mahogany table costs $310";
break;
default:
message = "Invalid input. Please enter P, O, or M.";
break;
}
// Show result in a dialog box
JOptionPane.showMessageDialog(null, message);
} else {
JOptionPane.showMessageDialog(null, "No input provided.");
}
}
}