Java program is not calculating total?
I have to write a program that prompts the user to make a choice of food then adds the total. The user needs to prompted 3 times.
When I run the program it only gives me a total of zero. Why is it not calculating the total?
import javax.swing.JOptionPane; public class FastFood { double total = 0; public static void main(String[] args) { double choice = getChoice(); if (choice == 0) JOptionPane.showMessageDialog(null, "Your total is $0.00."); else { calculateTotal(total, choice); choice = getChoice(); if (choice == 0) JOptionPane.showMessageDialog(null, "Your Total is:" + total ); else { calculateTotal(total, choice); choice = getChoice(); if (choice == 0) JOptionPane.showMessageDialog(null, "Your Total is:" + total ); else { calculateTotal(total, choice); JOptionPane.showMessageDialog(null, "Your Total is:" + total ); } } } } public static double getChoice() { String input = JOptionPane.showInputDialog(null, "Choose your meal Item" + "\n(1)Burger $4.99" + "\n(2)Pepsi $2.00" + "\n(3)Chips $0.75"); return Double.parseDouble(input); } public static void calculateTotal(double total, double choice) { if (choice == 1) total = total + 4.99; else if (choice == 2) total = total + 2.00; else if (choice == 3) total = total + 0.75; else JOptionPane.showMessageDialog(null, "Invalid choice enter numbers 0-3 only"); } }