Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The Myra Company sells five types of vehicles for the month of December 2020. Each vehicle is given a special discount as shown in Table

The Myra Company sells five types of vehicles for the month of December 2020. Each vehicle is given a special discount as shown in Table 4. At the end of the month, the company should produce a report consists of vehicle prices after discount along with the discount given, gross profit earned by each type of vehicle, and finally the gross profit earned by the company. Example of input and output as shown in Figure 1. ( Syarikat Myra menjual lima jenis kenderaan untuk bulan Disember 2020. Setiap kenderaan diberi diskaun seperti yang ditunjukkan dalam Table 4. Pada akhir bulan, syarikat perlu menghasilkan laporan yang terdiri daripada harga kenderaan setelah diskaun beserta diskaun yang diberikan, keuntungan kasar yang diperolehi oleh setiap jenis kenderaan dan akhirnya keuntungan kasar yang diperolehi oleh syarikat. Contoh input dan output adalah seperti yang ditunjukkan dalam Figure 1. ) Table 4: Vehicles Price Vehicle Name Cost Price Selling Price Discount MyraA RM45,000 RM55,000 5% MyraB RM59,000 RM74,000 5% MyraC RM68,000 RM84,000 5% MyraD RM85,500 RM105,500 10% MyraE RM125,000 RM150,000 10% MTS3063: Principles of Programming 8 [See next page Figure 1: Example of input and output a) Analyze the given problem and identify what is the input, output and process. ( Analisis masalah yang diberi dan kenal pasti apakah input, output dan proses. ) [10 marks] b) Write a complete C++ program that can compute and produce output as shown in Figure 1. You are also required to use at least 3 functions in your program. ( Tulis atur cara C++ yang lengkap yang dapat menggira dan menghasilkan output seperti yang ditunjukkan dalam Figure 1. Anda juga dikehendaki menggunakan sekurang-kurangnya 3 fungsi dalam program ini. ) [15 marks] Enter sales of each type of vehicle: MyraA : 3 MyraB : 2 MyraC : 5 MyraD : 4 MyraE : 1 Myra Company Report for December 2020 --------------------------------------------------------- MyraAs price after discount is RM52,250. Discount given is RM2,750. MyraBs price after discount is RM70,300. Discount given is RM3,700. MyraCs price after discount is RM79,800. Discount given is RM4,200. MyraDs price after discount is RM94,950. Discount given is RM10,550. MyraEs price after discount is RM135,000. Discount given is RM15,000. Gross profit earned by each type of vehicle -------------------------------------------------------------- MyraA = RM21,750 MyraB = RM22,600 MyRaC = RM59,000 MyraD = RM37,800 MyraE = RM10,000 Gross profit earned by Myra company is RM151,150. MTS3063: Principles of Programming 9 [See next page Question 2 In the Felisa Beauty competition, three candidates namely A, B, and C have entered the final competition. Ambassador Felisa Beauty, the champion of the competition, is based on the highest marks obtained from SMS votes. Voting is done by typing the word Felisa and followed by the name of the selected candidate which is either A, B or C. Suppose all votes received will be stored in an input file named UNDIAN.DAT as shown in Figure 2 where each vote represents 1 mark. The total marks for all candidates will be calculated in the main program and then these three marks will be sent to a function named Duta to determine the Ambassador Felisa and the results will be sent back to the main program for printing. Assume that the number of votes for each candidate is different from each other. (Di dalam pertandingan Felisa Beauty, tiga calon iaitu A, B dan C telah memasuki pertandingan akhir. Duta Felisa Beauty, johan pertandingan, adalah berdasarkan markah tertinggi yang diperolehi dari undian SMS. Undian dibuat dengan menaip perkataan Felisa dan diikuti dengan nama calon yang dipilih iaitu samada A, B atau C. Semua undian yang diterima akan disimpan di dalam fail input bernama UNDIAN.DAT seperti dalam Figure 2 di mana setiap undian mewakili 1 markah. Jumlah markah bagi semua calon akan dikira di dalam main program dan seterusnya ketiga-tiga markah ini akan dihantar ke fungsi bernama Duta untuk menentukan Duta Felisa dan hasil keputusannya akan dihantar semula ke main program untuk di cetak. Anggap jumlah undian bagi setiap calon adalah berbeza antara satu sama lain.) Figure 2: Voting Figure 2 : Content of input file Felisa A Felisa B Felisa B Felisa A Felisa C : : . MTS3063: Principles of Programming 10 [See next page a) Analyze the given problem and identify what is the input, output and process. ( Analisis masalah yang diberi dan kenal pasti apakah input, output dan proses. ) [5 marks] b) Write a complete C++ program that determines and prints a candidate who will be the Ambassador Felisa Beauty.) ( Tulis atur cara C++ yang lengkap bagi menentukan dan mencetak calon yang akan menjadi Duta Felisa Beauty. )image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

MTS3063: Principles of Programming 7 SECTION B: (50 marks) Instruction: Answer all questions. (Arahan: Jawab semua soalan.) Question 1 The Myra Company sells five types of vehicles for the month of December 2020. Each vehicle is given a special discount as shown in Table 4. At the end of the month, the company should produce a report consists of vehicle prices after discount along with the discount given, gross profit earned by each type of vehicle, and finally the gross profit earned by the company. Example of input and output as shown in Figure 1. (Syarikat Myra menjual lima jenis kenderaan untuk bulan Disember 2020. Setiap kenderaan diberi diskaun seperti yang ditunjukkan dalam Table 4. Pada akhir bulan, syarikat perlu menghasilkan laporan yang terdiri daripada harga kenderaan setelah diskaun beserta diskaun yang diberikan, keuntungan kasar yang diperolehi oleh setiap jenis kenderaan dan akhirnya keuntungan kasar yang diperolehi oleh syarikat. Contoh input dan output adalah seperti yang ditunjukkan dalam Figure 1.) Table 4: Vehicles Price Cost Price Selling Price Vehicle Name Discount MyraA MyraB Myrac MyraD MyraE RM45,000 RM59,000 RM68,000 RM85,500 RM125,000 RM55,000 RM74.000 RM84,000 RM105,500 RM150,000 5% 5% 5% 10% 10% Enter sales of each type of vehicle: MyraA : 3 MyraB : 2 MyraC : 5 MyraD : 4 MyraE : 1 Myra Company Report for December 2020 MyraA's price after discount is RM52,250. Discount given is RM2,750. MyraB's price after discount is RM70,300. Discount given is RM3,700. MyraC's price after discount is RM79,800. Discount given is RM4,200. MyraD's price after discount is RM94,950. Discount given is RM10,550. MyraE's price after discount is RM135,000. Discount given is RM15,000. Gross profit earned by each type of vehicle MyraA = RM21,750 MyraB = RM22,600 MyRaC = RM59,000 MyraD = RM37,800 MyraE = RM10,000 Gross profit earned by Myra company is RM151,150. Figure 1: Example of input and output a) Analyze the given problem and identify what is the input, output and process. ( Analisis masalah yang diberi dan kenal pasti apakah input, output dan proses.) [10 marks] b) Write a complete C++ program that can compute and produce output as shown in Figure 1. You are also required to use at least 3 functions in your program. (Tulis atur cara C++ yang lengkap yang dapat menggira dan menghasilkan output seperti yang ditunjukkan dalam Figure 1. Anda juga dikehendaki menggunakan sekurang-kurangnya 3 fungsi dalam program ini.) [15 marks (See next page MTS3063: Principles of Programming 9 Question 2 In the Felisa Beauty competition, three candidates namely A, B, and C have entered the final competition. Ambassador Felisa Beauty, the champion of the competition, is based on the highest marks obtained from SMS votes. Voting is done by typing the word Felisa and followed by the name of the selected candidate which is either A, B or C. Suppose all votes received will be stored in an input file named UNDIAN.DAT as shown in Figure 2 where each vote represents 1 mark. The total marks for all candidates will be calculated in the main program and then these three marks will be sent to a function named Duta to determine the Ambassador Felisa and the results will be sent back to the main program for printing. Assume that the number of votes for each candidate is different from each other. (Di dalam pertandingan Felisa Beauty, tiga calon iaitu A, B dan C telah memasuki pertandingan akhir. Duta Felisa Beauty, johan pertandingan, adalah berdasarkan markah tertinggi yang diperolehi dari undian SMS. Undian dibuat dengan menaip perkataan Felisa dan diikuti dengan nama calon yang dipilih iaitu samada A, B atau C. Semua undian yang diterima akan disimpan di dalam fail input bernama UNDIAN.DAT seperti dalam Figure 2 di mana setiap undian mewakili 1 markah. Jumlah markah bagi semua calon akan dikira di dalam main program dan seterusnya ketiga-tiga markah ini akan dihantar ke fungsi bernama Duta untuk menentukan Duta Felisa dan hasil keputusannya akan dihantar semula ke main program untuk di cetak. Anggap jumlah undian bagi setiap calon adalah berbeza antara satu sama lain.) Felisa A Felisa B Felisa B Felisa A Felisa C Figure 2 : Content of input file [See next page MTS3063: Principles of Programming 10 a) Analyze the given problem and identify what is the input, output and process. Analisis masalah yang diberi dan kenal pasti apakah input, output dan proses.) 15 marks b) Write a complete C++ program that determines and prints a candidate who will be the Ambassador Felisa Beauty.) (Tulis atur cara C++ yang lengkap bagi menentukan dan mencetak calon yang akan menjadi Duta Felisa Beauty.) [20 marks END OF QUESTIONS (SOALAN TAMAT)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago