Created
January 28, 2017 19:00
-
-
Save asg5704-deprecated/a0966747fdc3e0dab5356ec387d33324 to your computer and use it in GitHub Desktop.
Assignment 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import javax.swing.JOptionPane; | |
| public class CircuitBoard | |
| { | |
| public static void main(String [] args) | |
| { | |
| String answer; | |
| double retailPrice; | |
| double profit; | |
| double rate = 0.4; | |
| String formatter; | |
| answer = JOptionPane.showInputDialog("What is the retail price of your circuit board?"); | |
| retailPrice = Double.parseDouble(answer); //Parses String data to find double | |
| profit = retailPrice * rate; | |
| formatter = String.format("%.2f", profit); //Formats string to two-decimal places | |
| JOptionPane.showMessageDialog(null, "You entered $" + retailPrice + " Your profit is $" + formatter); | |
| }//end main | |
| }//end class |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment