Question

Q: write a program in LISP Programming language for the following condition: Users may order one...

Q: write a program in LISP Programming language for the following condition:

Users may order one or more pizzas, where each pizza may be either: small, medium or large. Small pizzas cost $5, medium pizzas cost $8 and large pizzas cost $12.

All pizzas come on a tomato base (for our pizza shop, this will be the only option), and will have the topping cheese by default, at no extra cost. Users may choose up to a maximum of four additional toppings (bringing the total to five) from the following list, where each topping adds an additional $1 to the price of the pizza:

• Bacon,

• Olives,

• Ham,

• Mushrooms,

• Pineapple,

• Salami,

• Anchovies.

A pizza order consists of an order for one or more pizzas, where each pizza has a size, and may optionally include a list of up to four additional toppings. Each pizza order must be marked as either to be collected or to be delivered. If the pizza is to be collected then the order requires a name and a phone number to be valid. If the pizza is to be delivered then a name, phone number and address are required to be valid. In addition, if the order total is less than $30 then an $8 delivery fee is added to the total. The application must be error tolerant and capable of accepting keyboard input to store a number of pizza orders in memory (they do not have to be persisted to file), as well as displaying an order summary which include details of all orders, including:

• The details of each pizza in the order,

• The total cost of the order, and

• The name, phone number and (if required) address of the person who made the order.

Homework Answers

Answer #1

code:

(defvar *pizzalist* nil)
(defvar *singlepizza* nil)
(defvar *toppinglist* nil)
(defvar *totalcost* nil)
(setf *totalcost* 0)
(defvar *toppingcost* nil)
(setf *toppingcost* 0)
(defvar *pcount* nil)
(setf *pcount* 0)

(defvar *toppings* (list 1 2 3 4 5 6 7) )
(defvar *validtoppingsstring* (list "Bacon" "Olives" "Ham" "Mushrooms" "Pineapple" "Salami" "Anchovies" ) )
(defvar *ynarray* (list 1 2))
(defvar *pizzasizearray* (list 1 2 3))


(defun add_pizza_to_list (pizza_to_add)
   (push pizza_to_add *order-pizza-list*)
)

(defun add_toppings (toppint_to_add)
   (push toppint_to_add *order-pizza-list*)
)

; Function to print a prompt and read a line of input
(defun prompt-read (prompt)
   (format *query-io* "~a: " prompt)
   (read *query-io*)
)

(defun topping_name (n)
   (decf n)
;"Returns the Nth element of LIST.
;N counts from zero. If LIST is not that long, nil is returned."
(car (nthcdr n *valid_toppings_string*)))


(defun printList (list)
   (loop for item in list
       do (format t " ~s" (topping_name item))
   )
)

(defun get_toppings(list)

   (if (null list)
       (print "")
           (progn
               (setq top1 (car list))
               (print top1)
               (setq other_top (cdr list))
               (get_toppings other_top )
           )
   )
   )

(defun get_list_length (list)
(if list
(1+ (get_list_length (cdr list)))
0))

(defun print_order(list)

   (if (null list)
       (print "")
           (progn
               (incf *pcount*)
               (format t "~C" #\linefeed)
               (format t "Pizza ~s Detail:" *pcount*)
               (setq single_pizza (car list))
               ;(print "Single pizza: ")
               ;(print single_pizza)
               (setq toppings (car single_pizza))
               (print "Toppings:")
               ;(print (get_list_length toppings))
               (setf top_price (get_list_length toppings))
               (setf *topping_cost* (+ top_price *topping_cost* ))
               ;(print toppings)
               (printList toppings)

               (setq price_size (cdr single_pizza))
               (setq price (car price_size))
               (print "Price:")
               (format t " ~s" price)
               (setf *total_cost* (+ price *total_cost* ))
               ;(print price)
               (setq size (cdr price_size))
               (print "Size:")
               ;(print size)
               (format t " ~s" size)
               (setq newlist (cdr list))
               (print "--------------------------------------------------------------------------------------")
               (print_order newlist )
           )
   )
   )

(defun main()
  
   (setf *single_pizza* nil)
   (setf *topping_list* nil)

   (print "Select Pizza Size: 1 = Large ($12) | 2 = Medium ($8) | 3 = Small ($5)")

   (loop
       (print "Your choice: ")
       (setq choice (read))
       (if (not (find choice *pizzasizearray* :test #'equalp))
           (format T "Invalid choice: Please Enter 1 or 2 or 3")
           (return)
          
       )
   )

   (if (= 1 choice)
       (progn
       (setf price 12)
       (push "Large" *single_pizza*)
       (push 12 *single_pizza*)
       )
   )

   (if (= 2 choice)
       (progn
       (setf price 8)
       (push "Medium" *single_pizza*)
       (push 8 *single_pizza*)
       )
   )

   (if (= 3 choice)
       (progn
       (setf price 5)
       (push "Small" *single_pizza*)
       (push 5 *single_pizza*)
       )
   )

   (defvar topping nil)
   (defvar topping_count nil)
   (setf topping_count 1)
   (print "Select Toppings: 1 = Bacon | 2 = Olives | 3 = Ham | 4 = Mushrooms | 5 = Pineapples | 6 = Salami | 7 = Anchovies")
   ;(print "Maximum four topping allowed.")
   (loop

       (print "Which topping do you like to add?")
           (setq topping (read))

           (if (not (find topping *valid_toppings* :test #'equalp))
               (format T "Invalid choice - please choose 1 to 7.~%")
               (progn
                   ;(format t "Topping count ~a.~%~%" topping_count)
                   (if (not (null topping))
                       (progn
                           (incf topping_count)
                           (push topping *topping_list*)
                           )

                       )
                   ;(format T "Topping selected ~a.~%~%" topping)
                   (if (> topping_count 4)
                       (progn
                           (print "You have selected four topping!! which is maximum value.")
                           (return)
                       )
                       (progn
                           (loop
                               (print "Do you like to add more topping? 1 = Yes | 2 = No")
                               (setq ynvalue (read))
                               (if (not (find ynvalue *ynarray* :test #'equalp))
                                   (format T "Invalid choice - please choose 1 or 2.~%")
                                   (return)
                                  
                               )
                           )
                           (if (= ynvalue 2)
                               (return)
                           )
                       )                  
                   )
               )
       )
   )


       ;(print *topping_list*)
       (push *topping_list* *single_pizza*)
       ;(print *single_pizza*)
       (push *single_pizza* *pizza_list*)
       ;(print *pizza_list*)
)


(main)


(loop
   (print "Do you like to add more pizza? 1 = Yes | 2 = No")
   (setq ynvalue (read))
   (if (not (find ynvalue *ynarray* :test #'equalp))
       (format T "Invalid choice - please choose 1 or 2.~%")
       (progn
           (if (= ynvalue 1)
               (main)
               (return)
           )

           )
          
   )
)

(print "Enter Your Name: ")
(setq name (read))

(print "Enter Your Phone: ")
(setq phone (read))

(loop
   (print "Select Delivary type? 1 = Delivary | 2 = Collected")
   (setq ynvalue (read))
   (if (not (find ynvalue *ynarray* :test #'equalp))
       (format T "Invalid choice - please choose 1 or 2.~%")
       (progn
           (if (= ynvalue 1)
               (progn
                   (print "Enter Your Address: ")
                   (setq address (read))
                   (return)
                   )
               (return)
           )

           )
          
   )
)

;(print "Final")
;(print *pizza_list*)
(format t "~C" #\linefeed)
(format t "~C" #\linefeed)
(print "Your Order Details:")
(format t "~C" #\linefeed)
;(print "*********************************************************************************************")
(print "*********************************************************************************************")

(print_order *pizza_list* )


(print "Delivary type: ")
(if (= ynvalue 1)
   (format t " ~s" "Delivary")
   (format t " ~s" "Collected")
   )


(print "Name: ")
(format t " ~s" name)

(print "Phone:")
(format t " ~s" phone)

(if (= ynvalue 1)
   (progn
       (print "Address: ")
       (format t " ~s" address)

       )
   )

;(print "Topping price: ")
;(format t " ~s" *topping_cost*)
(setf *total_cost* (+ *topping_cost* *total_cost*))
;(print "Total Price: $")
;(format t " ~s" *total_cost*)
(format t "~C" #\linefeed)
(format t "Total Price: $~s" *total_cost*)


(if (and (= ynvalue 1) (< *total_cost* 30))
   (progn
       (print "Here total price is less than $30. so $8 Delivary fee will be added.")
       (setf *total_cost* (+ 8 *total_cost*))
       )
   )
;(print "Total Cost: $")

(format t "~C" #\linefeed)
(format t "Total Price: $~s" *total_cost*)


(format t "~C" #\linefeed)
;(print "*********************************************************************************************")
(print "*********************************************************************************************")
(format t "~C" #\linefeed)
(format t "~C" #\linefeed)
output:-

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
***Programming language is Java. After looking at this scenario please look over the requirements at the...
***Programming language is Java. After looking at this scenario please look over the requirements at the bottom (in bold) THIS IS ALL THAT WAS PROVIDED. PLEASE SPECIFY ANY QUESTIONS IF THIS IS NOT CLEAR (don't just say more info, be specific)*** GMU in partnership with a local sports camp is offering a swimming camp for ages 10-18. GMU plans to make it a regular event, possibly once a quarter. You have been tasked to create an object-oriented solution to register,...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
for the scenario below: 1) Apply the qualitative analysis by identifying at least 3 issues in...
for the scenario below: 1) Apply the qualitative analysis by identifying at least 3 issues in the above process. Analyse these issues by using a. Adding-value and Waste Analysis b. Issue register, If you find that there are more than three issues, you can focus on the three issues that have the highest impact. 2). Calculate the cycle time efficiency of the as-is process. You can assume a working week of 40 hours. In case there is missing information, you...
      MK Restaurant: Branding of Thai-Style Hotpot The restaurant industry is one of the most...
      MK Restaurant: Branding of Thai-Style Hotpot The restaurant industry is one of the most competitive in Thailand. With a large number of players ranging from restaurants in five-star hotels, global fast-food chains to small stalls along the streets and everything in between, the Thais are spoiled for choice. In addition, as the world becomes globalized, consumers are familiar with international dishes and would not hesitate to try new offerings from the other side of the globe. As a...
Background You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting...
Background You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting firm with offices throughout the major regional centres of NSW and Queensland. Although a medium sized firm by national standards, MYH is the second largest regional accounting firm in Australia. Most of MYH’s audit clients are in the agriculture, mining, manufacturing and property industries. All of those industries are currently under pressure, either from a downturn in commodity prices or fierce competition from overseas...
You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting firm...
You are a manager in the audit division at Miller Yates Howarth (MYH), an accounting firm with offices throughout the major regional centres of NSW and Queensland. Although a medium sized firm by national standards, MYH is the second largest regional accounting firm in Australia. Most of MYH’s audit clients are in the agriculture, mining, manufacturing and property industries. All of those industries are currently under pressure, either from a downturn in commodity prices or fierce competition from overseas competitors....
1. The failure of the new supply chain system affected Nike adversely. What were the reasons...
1. The failure of the new supply chain system affected Nike adversely. What were the reasons for the failure and how did the breakdown harm Nike? 2. What are the important elements to be kept in mind while implementing a new system in an organization? What is the importance of a good working relationship between partners and the sharing of responsibility in implementing critical projects? What mistakes did Nike and i2 make? 3. comment on the lessons learned and the...
GoodClothes and MIS: Case from struggle to revamp Headquartered in Dubai, GoodClothes is a highly successful...
GoodClothes and MIS: Case from struggle to revamp Headquartered in Dubai, GoodClothes is a highly successful department retailer offering completely designed casual clothing and accessories. The company operates 10 stores in all seven emirates and 1 store in Al Ain. The company owns 6 stores and franchises 5. For some time, marketing managers targeted population between the ages 40 and 60 who like loose, comfortable clothes. Then, management was tempted to stock its stores with clothes for a younger population...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From...
Sign In INNOVATION Deep Change: How Operational Innovation Can Transform Your Company by Michael Hammer From the April 2004 Issue Save Share 8.95 In 1991, Progressive Insurance, an automobile insurer based in Mayfield Village, Ohio, had approximately $1.3 billion in sales. By 2002, that figure had grown to $9.5 billion. What fashionable strategies did Progressive employ to achieve sevenfold growth in just over a decade? Was it positioned in a high-growth industry? Hardly. Auto insurance is a mature, 100-year-old industry...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT