File tree 2 files changed +30
-0
lines changed
Programming-Challenges/Fundamentals
out/production/Programming-Challenges/com/challenges 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments