Question: Can i have the answer (codes) for question 3 please. i am not receiving the desired output. I have attempted the question a little. Please

Can i have the answer (codes) for question 3 please. i am not receiving the desired output.

I have attempted the question a little. Please help me improve it.

belummakan.h

#include #include #include using namespace std;

class belumMakan { protected: string firstName, lastName, type; int numOfOrder; double price; virtual void calculate (void) = 0 ; public: belumMakan(){} belumMakan (string FN, string LN, int NOO) { firstName = FN; lastName = LN; numOfOrder = NOO; } void displayOrder() { cout

//class rotiCanai

class rotiCanai : public belumMakan { public : rotiCanai() {} rotiCanai(string FN, string LN, int NOO) : belumMakan (FN,LN,NOO)//constructor { type = "Roti Canai"; calculate(); } private : void calculate() { price = numOfOrder * 1.50; } };

//class nasiGoreng

class nasiGoreng : public belumMakan { public: nasiGoreng() {} nasiGoreng(string FN, string LN, int NOO) : belumMakan (FN, LN, NOO)//constructor { type = "Nasi Goreng"; calculate(); } private: void calculate () { price = numOfOrder * 7.80; } };

main.cpp

#include #include "belummakan.h" #include using namespace std; int main() { int numOfOrder,num; string firstName, lastName; int i, type; belumMakan *t[50]; cout> num; cout press 1 nasiGoreng\t-> press 2 "; cout > type; cout > firstName; cout > lastName; cout > numOfOrder; cout or 2 for nasiGoreng Seat "

cout displayOrder(); cout

return 0; }

Can i have the answer (codes) for question 3 please. i am

SECTION C: DESIGNING/ PROGRAMMING (3 QUESTIONS, 40 MARKS) Instruction: Please answer ALL the questions. Question 1 Refer to Table 1, 2 and 3 below. Construct a Unified Modeling Language (UML) Class Diagram to represent all THREE (3) classes where class rotiCanas and class nasi Goreng will both inherit from class belakan Table 1: Class belum Makan class Member Type ACCOSS void calculate void Virtual protected firstName string protected last Name string protected type string protected numotorder int protected price double protected belum Makan (FN: string. LN: string. NOO - public void displayOrder (void) public Question 2 Referring to the class diagram you have constructed in Question I, write a program in a file named belumnakan.h consisting of THREE (3) classes class belukan, class roti Canai and class nasi goreng. Several mechanisms that need to be included in this file une Function calculate in class belum akan is a virtual function where function operation differs respectively in classroticanal and nasi Goreng The constructor in class belulakan will assign THREE (3) values through its parameters to variable first , lastame, and nanoorder respectively Function displayOrder t) will call function calculate to calculate the value of variable price before displaying the following output shown in Figure 13 person Name Theactorcrybaby. Ronaldo: Makan-akan for You will makan Roti Canal Total Price: 4.50 Table 2: Class roti Canai Class Member rotiCanai (FN:string, LN: string. NOOI string) void calculate (void) Figure 13 Both constructors in class zoti Canai and nasi Goreng will inherit the constructor of class belum lakan. Also, variable type is initialized with string "Roti Canai" through the constructor of class roticanai. While variable type is initialized with string "Naal Goreng" through the constructor of ACCOSS public private class nasi Goreng Table 3: Class nasi Goreng class Member nasi Goreng (FN: string, LN: string, NOO: string) void calculate (void) ACCOSS public Function calculate in class roti Canai will calculate the value of price A roti canai costs RM 1.50 each. Function calculate will multiply RM 1.50 with numotorder. Function calculate() in class nasi Goreng will calculate the value of price. A nasi goreng costs RM 7.80 each. Function calculate will multiply RM 7.80 with numoorder, 120 marks) private (5 marks) Order bekani Insert cuts tirata It C Tas Theert aber of oudert Ronaldo metery Thor de pay Cantidad Theactory , Ronald a for 3 person Question 3 Referring to Question 2 write a program in another file named themain.cpp in order to execute the classes created in Question 2. The program should prompt users to input the type of food (roti canai or nasi goreng) before proceeding to asking for each order's first name, last name, and number of orders. Your program williterate to reserve the orders until character or "n" is keyed in as a sentinel value to stop the program Your maint) function should contain the following elements belum akan *150); *150) is a class belumbakan pointer array that instantiate list of objects from both class roti Canai and class naslorong Sufficient variables to preliminary store values for first name, last name, number of orders, food type, loop counters and sentinel value. Variable type is used for food type selection. If type - 1, an object pointer for class cotiCanal is created, while if type 2, an object pointer for class nasi Goreng is created. You may use any preferred selection structure, Member function displayOrder will be called before the end of each loop Refer to Figure 14 for the final output -display Confined Order 2 Ses Thecollzollguy. Na w at op Total 31.20 Continue Order? Y DE Figure 14 15 mars

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!