Skip to content

Instantly share code, notes, and snippets.

@asg5704-deprecated
Created January 28, 2017 19:00
Show Gist options
  • Select an option

  • Save asg5704-deprecated/a0966747fdc3e0dab5356ec387d33324 to your computer and use it in GitHub Desktop.

Select an option

Save asg5704-deprecated/a0966747fdc3e0dab5356ec387d33324 to your computer and use it in GitHub Desktop.
Assignment 1
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