bajapro/online-compiler/java_files/seli_gmail_com/OrderCase.java
2025-06-07 16:18:13 +07:00

45 lines
994 B
Java
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package seli_gmail_com;
public class OrderCase {
boolean isFilled;
double billAmount;
String shipping;
public OrderCase(boolean filled, double cost, String shippingMethod) {
isFilled = filled;
billAmount = cost;
shipping = shippingMethod;
}
public void ship() {
if (isFilled) {
System.out.print("Shipping cost: " + calculateShipping());
} else {
System.out.print("Order not ready");
}
}
public double calculateShipping() {
double shippingCost;
// declare switch statement here
switch (shipping) {
case "Regular":
shippingCost = 0;
break;
case "Express":
shippingCost = 1.75;
break;
default:
shippingCost = 0.50;
}
return shippingCost;
}
public static void main(String[] args) {
// do not alter the main method!
OrderCase book = new OrderCase(true, 9.99, "Express");
book.ship();
  }
}