Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. public class Order {
  2. boolean isFilled;
  3. double billAmount;
  4. String shipping;
  5.  
  6. public Order(boolean filled, double cost, String shippingMethod) {
  7. if (cost > 24.00) {
  8. System.out.println("High value item!");
  9. }
  10. isFilled = filled;
  11. billAmount = cost;
  12. shipping = shippingMethod;
  13. }
  14.  
  15. public void ship() {
  16. if (isFilled) {
  17. System.out.println("Shipping");
  18. System.out.println("Shipping cost: " + calculateShipping());
  19. } else {
  20. System.out.println("Order not ready");
  21. }
  22. }
  23.  
  24. public double calculateShipping() {
  25. // declare conditional statement here
  26. if (shipping.equals("Regular"))
  27. return 0;
  28. } else if (shipping.equals("Express")) {
  29. return 1.75;
  30. } else {
  31. return .50;
  32. }
  33.  
  34. public static void main(String[] args) {
  35. // do not alter the main method!
  36. Order book = new Order(true, 9.99, "Express");
  37. Order chemistrySet = new Order(false, 72.50, "Regular");
  38.  
  39. book.ship();
  40. chemistrySet.ship();
  41. }
  42. }
  43.  
  44. Order.java:28: error: illegal start of type
  45. } else if (shipping.equals("Express")) {
  46. ^
  47. Order.java:28: error: <identifier> expected
  48. } else if (shipping.equals("Express")) {
  49. ^
  50. Order.java:28: error: illegal start of type
  51. } else if (shipping.equals("Express")) {
  52. ^
  53. Order.java:30: error: illegal start of type
  54. } else {
  55. ^
  56. 4 errors
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement