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.print("please enter package weight in kilos: ");
int weight = input.nextInt();
int cost = 0;
if (weight > 0 && weight <= 1)
cost = 5;
else if (weight > 1 && weight <= 3)
cost = 10;
else
{
System.out.println("Sorry, we cannot ship your package.");
System.exit(0);
}
System.out.println("Cost of shipping for your 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.