I have been staring at this for longer than I care to admit, I dont know why it says the variable hold may not have been initialized? Looks initialized to me. You guys are the best any insight you may have would be awesome.
1 error found:
File: E:\ClassPractice1\ClassPractice1\Question1_IfState ment.java [line: 32]
Error: The local variable hold may not have been initialized
import javax.swing.JOptionPane; import java.text.DecimalFormat; //This program practices JOptionPane and an IF statement. public class Question1_IfStatement { public static void main(String[] args) { String inputString; double first; double second; double hold; DecimalFormat formatter = new DecimalFormat("#0.00"); inputString = JOptionPane.showInputDialog ("What is the first number: "); first = Double.parseDouble (inputString); inputString = JOptionPane.showInputDialog ("What is the second number: "); second = Double.parseDouble (inputString); if (first >= second) { hold = (first * second) + (first * 2); } if (second > first) { hold = (first + second) + (second * 5); } JOptionPane.showMessageDialog(null, formatter.format(hold)); System.exit(0); } }