I have written this code, however, every time I input a decimal value, it doesn't work. How can I make this code work even if I input a decimal value? For example, if I input a value of 7.5, it should display that "the shipping cost is $9.45"
import java.util.Scanner;
public class IfElse {
public static void main(String[] args) {
int marksObtained;
Scanner input = new Scanner(System.in);
System.out.println("Please enter a package weight in pounds:");
marksObtained = input.nextInt();
if (marksObtained>20)
{
System.out.println("The package is too heavy to be shipped");
}
else if (marksObtained>10)
{
System.out.println("The shipping cost is $12.50");
}
else if (marksObtained>3)
{
System.out.println("The shipping cost is $9.45");
}
else if (marksObtained>1)
{
System.out.println("The shipping cost is $4.95");
}
else if (marksObtained>0)
{
System.out.println("The shipping cost is $2.95");
}
else if (marksObtained<0)
{
System.out.println("The weight must be greater than zero");
}
}
}