hmm it does look like you are taking a slightly more complicated rout than i would have taken and your syntax is something out of the ordinary... but to be honest there is no correct rout there is only a correct answer. now are you using an ide? if so i would recommend looking into the debugger it can help you out a ton. but for the sake of this answer i will tell you whats wrong. Here's what i did :
Code:
import java.util.Scanner;
public class MyShippingCharges {
public static void main(String[] args) {
//initialize variables (this is done within main because its unnessessary to have so many methods)
int milesShipped;
double weightOfPackage, tax = 1.7, tax1 = 2.2, tax2 = 6.7, tax3 = 9.8, result;
//ask user input
Scanner input = new Scanner(System.in);
System.out.println("Enter the weight of package in KG :");
weightOfPackage = input.nextDouble();
System.out.println("Enter distance shipped in miles :");
milesShipped = input.nextInt();
//first lets check how far the item traveled so we can get our multiplier
float multiplier = 0;
if (milesShipped <= 1000){
multiplier = 1;
}else {
multiplier = milesShipped / 1000;
}
//second ill check the weight of the package
if (weightOfPackage >= 10){
//now multiply the tax by the (multiplier)
result = multiplier*tax3;
}else if (weightOfPackage >= 5){
result = multiplier*tax2;
}else if (weightOfPackage >= 1){
result = multiplier*tax1;
}else {
result = multiplier*tax;
}
System.out.println("Your extimated cost will be : "+result);
System.out.println("Thanks for using P4$$1V3's tax calculator!");
}
}
Please leave a thanks if this helped you