This is the part where I ask the user to input the following.
Enter the item name: Shirt
Original price of the item: 700
Marked-up Percentage: 20
Sales Tax Rate: 7
Output:
Item to be sold : Shirt
Original price of the item: 700.00
Price after mark-up: 840.00
Sales tax: 58.80
Final price of item: 898.80
so my question is how can I make that 20 and 7 input be read by the program as percentages.
import java.util.*;
import javax.swing.*;
public class lab3 {
public static void main(String[] args) {
JOptionPane jo=new JOptionPane();
String item=jo.showInputDialog("Item to be sold: ");
double Oprice=Double.parseDouble(
jo.showInputDialog("Original price of the item: "));
double mup=Double.parseDouble(
jo.showInputDialog("Marked-up percentage: "));
double str=Double.parseDouble(
jo.showInputDialog("Sales Tax Rate: "));
double pamu=(Oprice*mup)+Oprice;
double ST=pamu*str;
double result=pamu+ST;
String hold= "\n| Item to be sold \t: "+item+"\t |"
+"\n| Original price of the item \t: "+Oprice+"\t |"
+"\n| Price after mark-up \t: "+pamu+"\t |"
+"\n| Sales Tax \t: "+ST+"\t |"
+"\n| Final price of the item \t: "+result+"\t |";
jo.showMessageDialog(null, new JTextArea(hold));
}
}
That is my actual code. sorry if its messy. like I said still new to this