Hi Java fanatics,
I'm relatively new to the game, and there's this code that is giving me a few headaches. I was hoping one of you could help me figure out, what's the issue...
This is part of the code:The compiler shows me the following error...Code:public static int addAddress (String[] number, boolean[] front, double[] total) { int num = 0; double ffee = 0; /*boolean value = false;*/ do { number[num]= JOptionPane.showInputDialog(null, "Enter number of the cellphone."); front[num]= defineFront(num); total[num]= calcIndividualTotal(num, ffee); } while (++num < address.length && JOptionPane.showConfirmDialog(null, " another house?")==JOptionPane.YES_OPTION); return num; } public static double defineFront(int num, boolean[] front) { double fee = 0; oceanfront[num]= Boolean.parseBoolean(JOptionPane.showInputDialog(null, "What's the house's front? Please enter TRUE or FALSE.")); if (oceanfront[num]== true) { ... } return fee; }
I have tried using the line of code commented out, /*boolean value = false;*/. However, another error is displayed.Code:Inspection.java:33: error: method defineFront in class Inspection cannot be applied to given types; front[num]= defineFront(num); ^ required: int,boolean[] found: int reason: actual and formal argument lists differ in length 1 error
The compiler shows the following...
I know that boolean values are by default stored as false, once you create the array. However, I'm having trouble passing the variable to the method. What do you think is wrong?Code:Inspection.java:33: error: incompatible types: boolean cannot be converted to boolean[] front[num]= defineFront(num, value); ^ Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output error




Reply With Quote
