Conversion between an price before tax (BT) and after tax (AT)
Write a program that, in a menu, give to the user several choices :
- Convert price BT in AT
- Convert price AT in BT
- End the application
(if convert price BT in AT, price should be *1,196, if convert price AT in BT, price should be /1.196)
Here is my code (which is wrong for now!). Thanks in advance for your help!
public class Exercice_3 {
/**
* @param args
*/
public static void main(String[] args) {
int choice;
float price_BT, price_AT
do
{
choice = Integer.parseInt(JOptionPane.showInputDialog(null, "Enter your choice:" + "\n'1' to calculate the price AT from a price BT," + "\n'2' to calculate the price BT from a price AT" + "\n'3' to end the application."));
if (choice==1);
price_BT = Float.parseFloat(JOptionPane.showInputDialog(null, "Enter a price BT :" + choice1 (float price_BT, float price_AT)));
else if (choice==2)
price_AT= Float.parseFloat(JOptionPane.showInputDialog(null, "Enter a price AT :"+ choice2 (float price_BT, float price_AT)));
}
while(choice !=3);
System.out.println("You ended the application.");
}
private static Object choice2(float price_BT, float price_AT) {
return price_BT*(float)1.196;
}
private static Object choice1(float price_BT, float price_AT) {
{
return price_AT/(float)1.196;
}
}
}