hey every time i compile i get errors with the JOptionPane.showMessageDialog(s) in the switch statement any help would be great
""incompatible types
found : void""
here is the code
import java.util.Random;
import javax.swing.*;
public class Fish{
String size;
String type;
String location;
public String Fish(String type, String location, String size){
String input = JOptionPane.showInputDialog("Press:" + "\n" + "1 for Bass" + "\n" + "2 for White perch" + "\n" + "3 for Yellow cat fish"
+ "\n" + "4 for Spec Trout" + "\n" + "5 for Red fish" + "\n" + "6 for Grouper");
int choice = Integer.parseInt(input);
switch (choice){
case 1: String input1 = JOptionPane.showInputDialog("what is the size(length) of your bass?");
String input2 = JOptionPane.showInputDialog("where did you catch your bass?");
double siz = Double.parseDouble(input1);
double loc = Double.parseDouble(input2);
String output = JOptionPane.showMessageDialog(null, "Sorry but you bass is not big enough to keep so through it back or i will tell on you");
String output1 = JOptionPane.showMessageDialog(null, "You caught a fresh water bass that is " + siz + "inches long and you caught it in " + loc);
if (siz <= 13)
return output;
else
return output1;
break;
case 2: String input3 = JOptionPane.showInputDialog("what is the size(length) of your White perch?");
String input4 = JOptionPane.showInputDialog("where did you catch your White perch?");
double siz1 = Double.parseDouble(input3);
double loc1 = Double.parseDouble(input4);
String output2 = JOptionPane.showMessageDialog(null, "Sorry but you White perch is not big enough to keep so through it back or i will tell on you");
String output3 = JOptionPane.showMessageDialog(null, "You caught a fresh water White perch that is " + siz1 + "inches long and you caught it in " + loc1);
if (siz1 <= 0)
return output2;
else
return output3;
break;
case 3:String input5 = JOptionPane.showInputDialog("what is the size(length) of your Yellow cat fish?");
String input6 = JOptionPane.showInputDialog("where did you catch your Yellow cat fish?");
double siz2 = Double.parseDouble(input5);
double loc2 = Double.parseDouble(input6);
String output4 = JOptionPane.showMessageDialog(null, "Sorry but you Yellow cat fish is not big enough to keep so through it back or i will tell on you");
String output5 = JOptionPane.showMessageDialog(null, "You caught a fresh water Yellow cat fish that is " + siz2 + "inches long and you caught it in " + loc2);
if (siz1 <= 10)
return output4;
else
return output5;
break;
case 4:String input7 = JOptionPane.showInputDialog("what is the size(length) of your Spec Trout?");
String input8 = JOptionPane.showInputDialog("where did you catch your Spec Trout?");
double siz3 = Double.parseDouble(input7);
double loc3 = Double.parseDouble(input8);
String output6 = JOptionPane.showMessageDialog(null, "Sorry but you Spec Trout is not big enough to keep so through it back or i will tell on you");
String output7 = JOptionPane.showMessageDialog(null, "You caught a salt water Spec Trout that is " + siz3 + "inches long and you caught it in " + loc3);
if (siz1 <= 0)
return output6;
else
return output7;
break;
case 5:String input9 = JOptionPane.showInputDialog("what is the size(length) of your Red fish?");
String input10 = JOptionPane.showInputDialog("where did you catch your Red fish?");
double siz4 = Double.parseDouble(input9);
double loc4 = Double.parseDouble(input10);
String output8 = JOptionPane.showMessageDialog(null, "Sorry but you Red fish is not big enough to keep so through it back or i will tell on you");
String output9 = JOptionPane.showMessageDialog(null, "You caught a salt water Red fish that is " + siz4 + "inches long and you caught it in " + loc4);
if (siz1 <= 0)
return output8;
else
return output9;
break;
case 6:String input11 = JOptionPane.showInputDialog("what is the size(length) of your Grouper?");
String input12 = JOptionPane.showInputDialog("where did you catch your Grouper?");
double siz5 = Double.parseDouble(input11);
double loc5 = Double.parseDouble(input12);
String output10 = JOptionPane.showMessageDialog(null, "Sorry but you Grouper is not big enough to keep so through it back or i will tell on you");
String output11 = JOptionPane.showMessageDialog(null, "You caught a salt water Grouper that is " + siz4 + "inches long and you caught it in " + loc4);
if (siz1 <= 0)
return output10;
else
return output11;
break;
}
}
public boolean caught(){
if (Math.random()*(2)+(1)==1){
return true;
}
else
return false;
}
public int hooked(String lure, String time){
String input = JOptionPane.showInputDialog("What lure did you use?");
String input1 = JOptionPane.showInputDialog("What time did you catch your fish at? include P.M or A.M");
double lur = Double.parseDouble(input);
double tim = Double.parseDouble(input1);
JOptionPane.showMessageDialog(null, "You hooked you fish with a " + lur + "at " + tim);
}
}
""incompatible types
found : void""
here is the code
import java.util.Random;
import javax.swing.*;
public class Fish{
String size;
String type;
String location;
public String Fish(String type, String location, String size){
String input = JOptionPane.showInputDialog("Press:" + "\n" + "1 for Bass" + "\n" + "2 for White perch" + "\n" + "3 for Yellow cat fish"
+ "\n" + "4 for Spec Trout" + "\n" + "5 for Red fish" + "\n" + "6 for Grouper");
int choice = Integer.parseInt(input);
switch (choice){
case 1: String input1 = JOptionPane.showInputDialog("what is the size(length) of your bass?");
String input2 = JOptionPane.showInputDialog("where did you catch your bass?");
double siz = Double.parseDouble(input1);
double loc = Double.parseDouble(input2);
String output = JOptionPane.showMessageDialog(null, "Sorry but you bass is not big enough to keep so through it back or i will tell on you");
String output1 = JOptionPane.showMessageDialog(null, "You caught a fresh water bass that is " + siz + "inches long and you caught it in " + loc);
if (siz <= 13)
return output;
else
return output1;
break;
case 2: String input3 = JOptionPane.showInputDialog("what is the size(length) of your White perch?");
String input4 = JOptionPane.showInputDialog("where did you catch your White perch?");
double siz1 = Double.parseDouble(input3);
double loc1 = Double.parseDouble(input4);
String output2 = JOptionPane.showMessageDialog(null, "Sorry but you White perch is not big enough to keep so through it back or i will tell on you");
String output3 = JOptionPane.showMessageDialog(null, "You caught a fresh water White perch that is " + siz1 + "inches long and you caught it in " + loc1);
if (siz1 <= 0)
return output2;
else
return output3;
break;
case 3:String input5 = JOptionPane.showInputDialog("what is the size(length) of your Yellow cat fish?");
String input6 = JOptionPane.showInputDialog("where did you catch your Yellow cat fish?");
double siz2 = Double.parseDouble(input5);
double loc2 = Double.parseDouble(input6);
String output4 = JOptionPane.showMessageDialog(null, "Sorry but you Yellow cat fish is not big enough to keep so through it back or i will tell on you");
String output5 = JOptionPane.showMessageDialog(null, "You caught a fresh water Yellow cat fish that is " + siz2 + "inches long and you caught it in " + loc2);
if (siz1 <= 10)
return output4;
else
return output5;
break;
case 4:String input7 = JOptionPane.showInputDialog("what is the size(length) of your Spec Trout?");
String input8 = JOptionPane.showInputDialog("where did you catch your Spec Trout?");
double siz3 = Double.parseDouble(input7);
double loc3 = Double.parseDouble(input8);
String output6 = JOptionPane.showMessageDialog(null, "Sorry but you Spec Trout is not big enough to keep so through it back or i will tell on you");
String output7 = JOptionPane.showMessageDialog(null, "You caught a salt water Spec Trout that is " + siz3 + "inches long and you caught it in " + loc3);
if (siz1 <= 0)
return output6;
else
return output7;
break;
case 5:String input9 = JOptionPane.showInputDialog("what is the size(length) of your Red fish?");
String input10 = JOptionPane.showInputDialog("where did you catch your Red fish?");
double siz4 = Double.parseDouble(input9);
double loc4 = Double.parseDouble(input10);
String output8 = JOptionPane.showMessageDialog(null, "Sorry but you Red fish is not big enough to keep so through it back or i will tell on you");
String output9 = JOptionPane.showMessageDialog(null, "You caught a salt water Red fish that is " + siz4 + "inches long and you caught it in " + loc4);
if (siz1 <= 0)
return output8;
else
return output9;
break;
case 6:String input11 = JOptionPane.showInputDialog("what is the size(length) of your Grouper?");
String input12 = JOptionPane.showInputDialog("where did you catch your Grouper?");
double siz5 = Double.parseDouble(input11);
double loc5 = Double.parseDouble(input12);
String output10 = JOptionPane.showMessageDialog(null, "Sorry but you Grouper is not big enough to keep so through it back or i will tell on you");
String output11 = JOptionPane.showMessageDialog(null, "You caught a salt water Grouper that is " + siz4 + "inches long and you caught it in " + loc4);
if (siz1 <= 0)
return output10;
else
return output11;
break;
}
}
public boolean caught(){
if (Math.random()*(2)+(1)==1){
return true;
}
else
return false;
}
public int hooked(String lure, String time){
String input = JOptionPane.showInputDialog("What lure did you use?");
String input1 = JOptionPane.showInputDialog("What time did you catch your fish at? include P.M or A.M");
double lur = Double.parseDouble(input);
double tim = Double.parseDouble(input1);
JOptionPane.showMessageDialog(null, "You hooked you fish with a " + lur + "at " + tim);
}
}