Skip to content

Commit 5255098

Browse files
Circuit Board Profit
1 parent cc90a79 commit 5255098

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
An electronics company sells circuit boards at a 40 percent profit.
3+
If you know the retail price of a circuit board, you can calculate its profit with the following formula:
4+
Profit = Retail price × 0.4
5+
Write a program that asks the user for the retail price of a circuit board,
6+
calculates the amount of profit earned for that product, and displays the results on the screen.
7+
*/
8+
9+
package com.challenges;
10+
11+
import javax.swing.*;
12+
13+
public class CircuitBoardProfit {
14+
public static void main(String [] args) {
15+
16+
// Declare Variables
17+
double retailPrice;
18+
final double PROFIT_PERCENTAGE = 0.4;
19+
double profit;
20+
21+
String userOutputString = JOptionPane.showInputDialog("Please enter the retail price of the product");
22+
retailPrice = Double.parseDouble(userOutputString);
23+
24+
profit = retailPrice * PROFIT_PERCENTAGE;
25+
26+
JOptionPane.showMessageDialog(null, "The profit earned on " + retailPrice + " is " + profit);
27+
28+
System.exit(0);
29+
}
30+
}

0 commit comments

Comments
 (0)