Lab-3

Functions and Parameters

Pre-lab reading materials

Announcements

Lab Grading policy  

There are 3 question. The maximum score is 2, where each question is worth 1 point. Question 3 is extra credit. To get a grade, you must show your work to TA before your lab session ends. NO submission needed. Once you finish your work, please raise your hand and show your work to your TA during the last 10 minutes of lab. Please leave the lab when the lab session ends, since we need to spare room for the next section.

Lab Activity

           During the lab section today, you need to implement three individual functions for a program, with progressing complexities. We will also supply a                      sample function for you.

Steps You Need to Do

Running the program should look like:

Lab 3: Movie Tickets

Name: Englebert Humperdink,  Movie: Sing

How many people are going? 2

Total price is: 16

Enter discount value: 1

Total price including discount is: 15

Running the program a second time might look like:

Lab 3: Movie Tickets

Name: Fred A. Stair,  Movie: Singing in the Rain

How many people are going? 3

Total price is: 24

Enter discount value: 5

Total price including discount is: 19

Sample Code

#include <stdio.h>

// 1. Write the displayNameAndMovie() function here

// ...

// 2. Write the promptForHowManyPeopleGoing() function here

// ...

// 3. Write the computeDiscount() function here

// ...

int main()

{

   int peopleGoing = 0;

   int discountValue = 0;

   int totalWithDiscount = 0;

   printf("Lab 3: Movie Tickets \n");

   displayNameAndMovie();

    peopleGoing = promptForHowManyPeopleGoing();

    printf("%d", peopleGoing);

    printf("Total price is: %d \n", peopleGoing * 8);

    printf("Enter discount value: ");

    scanf("%d", &discountValue);

    totalWithDiscount = computeDiscount( peopleGoing * 8, discountValue);

    printf("Total price including discount is: %d \n", totalWithDiscount);

   return 0;

}

1-24-2017