ShippingCostCalc

package shippingcostcalc; import java.util.Scanner; /** * * @author anfal */ public class ShippingCostCalc { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Please enter package weight in Kilos: "); int weight = input.nextInt(); int cost = 0; if (weight > 0 && weight <= 1) //5$ , if 0 < w ≤ 1 --> x > 0 & x <= 1 { cost = 5; } else if (weight > 1 && weight <= 3) //10$ , if 1 < w ≤ 3 { cost = 10; } else { System.out.println("Sorry, we cannot ship your package"); System.exit(0); } System.out.println("cost for package is " + cost + "$"); } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.