cseb114: principle of programming quiz 1. rules no cheating no reference no discussion only best...

5
CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1

Upload: christopher-edwards

Post on 13-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1. Rules  No cheating  No reference  No discussion  Only best 5 quizzes will be counted in your final marks,

CSEB114: PRINCIPLE OF PROGRAMMING

Quiz 1

Page 2: CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1. Rules  No cheating  No reference  No discussion  Only best 5 quizzes will be counted in your final marks,

Rules

No cheating No reference No discussion Only best 5 quizzes will be counted in

your final marks, however, if you are caught cheating, one of your best 5 quizzes will be 0

Those who submitted the quiz later than the time given, will get 0

Good Luck

Page 3: CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1. Rules  No cheating  No reference  No discussion  Only best 5 quizzes will be counted in your final marks,

Questions

Create a pseudocode and a flowchart of a program that first prompts the user to enter values for the length of a car trip in kilometers, and the amount of gasoline (in gallons) in the car’s tank at the beginning and end of the trip, and then computes and prints the average gasoline consumption in kilometer per gallon for the trip. (10 marks) (10 marks)

Page 4: CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1. Rules  No cheating  No reference  No discussion  Only best 5 quizzes will be counted in your final marks,

Question

Write a pseudocode and flowchart of a program that reads three numbers from the user and then calculates the average of the numbers. The number can be any number, positive or negative. Display the average of the numbers. (10 marks)

Write a pseudocode and flowchart of a program that display a message indicating the educational level of a student based on the student’s number of years of schooling. Use the table below. Print a message to indicate invalid data as well.

Number of Years Educational Level

0 None

1-5 Elementary

6-8 Middle School

9-12 High School

More than 12 College

Page 5: CSEB114: PRINCIPLE OF PROGRAMMING Quiz 1. Rules  No cheating  No reference  No discussion  Only best 5 quizzes will be counted in your final marks,

Question

Write a pseudocode or flowchart for a program that estimates the temperature in a freezer (in °C) given the elapsed time (hours) since a power failure. Assume this temperature (T) is given by

where t is the time since the power failure. Your program should prompt the user to enter how long it has been since the start of the power failure in whole hours and minutes. Note that you need to convert the elapsed time into hours. For example, if the user entered 2 30 (2 hours 30 minutes), you would need to convert this to 2.5 hours.

202

4 2

t

tT