I am a beginner in Java language and I am getting problem with code which has the 'incompatible types: possible lossy conversion from double to int'. What can i do to fix this? I am totally lost it.
import javax.swing.*;
import java.text.*;
public class CalculateIncome{
public static void main(String[]args){
String s1, outMessage;
double monthlySales, income;
DecimalFormat num = new DecimalFormat(",###.00");
s1 = JOptionPane.showInputDialog("Enter the value of monthly sales:");
monthlySales = Double.parseDouble(s1);
switch(monthlySales) {
case 1:
income = 200.00+0.03*monthlySales;
break;
case 2:
income = 250.00+0.05*monthlySales;
break;
case 3:
income = 300.00+0.09*monthlySales;
break;
case 4:
income = 325.00+0.12*monthlySales;
break;
case 5:
income = 350.00+0.14*monthlySales;
break;
case 6:
income = 375.00+0.15*monthlySales;
default:
outMessage = ("For the monthly sales of $" +num.format(monthlySales)+ "\nThe income is"+num.format(income));
}
JOptionPane.showMessageDialog(null,outMessage,"QuickTest Program 5.5b", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}