1 / 6

LAB SESSION 5

LAB SESSION 5. STRUCT WITH FUNCTION. QUESTION 1. Given a struct definition: struct athleteRec { char name[30]; int age; char IC_number [20]; int score_event1; int score_event2; int score_event3; int totalScore ; }. QUESTION 1(continue).

aysha
Download Presentation

LAB SESSION 5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LAB SESSION 5 STRUCT WITH FUNCTION

  2. QUESTION 1 • Given a struct definition: • structathleteRec • { • char name[30]; • int age; • char IC_number[20]; • int score_event1; • int score_event2; • int score_event3; • inttotalScore; • }

  3. QUESTION 1(continue) • Write a function definition that will : • a) inputData() //input a data and return by value • b) calcTotal() // calculate a total score and return through reference parameter • c) calcAverage() //calculate an average of total score and return by value • d) displayReport() // display a report as below: • ***************************** • ATHLETE DATA: • Name : XXXXXXXXXXXX • IC Number : XXXXXX-XX-XXXX • Detail Score : • Event 1 : XXXX • Event 2 : XXXX • Event 3: XXXX • TOTAL SCORE : XXXXX • AVERAGE SCORE : XXXX • *****************************

  4. QUESTION 2 Write a C++ program to help a local restaurant owner to automate his/her breakfast billing system. The program should do the following tasks: • Show the customer the different breakfast items offered by the restaurant. • Allow the customer to select one item and the amount of item purchased from the menu. • Calculate and print the bill. Assume that the restaurant offers the following breakfast items:

  5. QUESTION 2(Continue) Your program must contain at least the following functions: • Function showMenu: this function shows the different items offered by the restaurant and tells the user how to select the items. • Function CalculateTotal: this function calculates the total price to be paid by the customer. The total price should include a 5% tax. • Function printCheck: this function prints the check. Your program should use a structure to store information about the customer’s purchase: menu item, item price, the amount of item, tax value and the total amount due.  A sample output is as follows: Thanks for dining at Jonny’s Place Plain egg 2 RM3.00 Tax RM0.15  Amount Due RM3.15

  6. QUESTION 3(ASSIGNMENt 2) • Afiqah’s Company want to automate their parking system. For the prototype, your program should input time in and time out for one car. The rate for the parking lot is given below: • Your program must use a struct to store a data and apply modular programming. Sample of the output as below: • Time In: 14.15 pm • Time Out : 17.00 pm • Charge : RM 2.50

More Related