Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Day15C {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- JolibeeMenu callJolibee = new JolibeeMenu();
- callJolibee.setFood("S1");
- callJolibee.setQuantity(3);
- System.out.println("total ordered: " + callJolibee.getTotal());
- }
- }
- class JolibeeMenu {
- private String food;
- private int quantity;
- private double total = 0;
- public void setFood(String food) {
- this.food = food;
- }
- public void setQuantity(int quantity) {
- this.quantity = quantity;
- }
- public double getTotal() {
- total += compute();
- return total;
- }
- private double compute() {
- double result = 0;
- switch (food.toUpperCase()) {
- case "S1":
- result += 60 * quantity;
- break;
- case "S2":
- result += 122 * quantity;
- break;
- case "S3":
- result += 130 * quantity;
- break;
- default:
- System.out.println("Food not on menu");
- }
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment