CPE 101-01, Turner

Fall 2008

 

SAMPLE PRACTICE Lab Exam 1 

October 10th , 2008 

(Lab exam next week!)



• Time to complete the exam: 50 minutes. 

• This exam is individual 

• This exam is open book 

• This exam is closed everything else, including lecture notes, electronic devices, etc 

• The only programs you are allowed to have open on the computer during this exam are: 

– The text editor of your choice on vogon

– Terminal window(s) 

– ssh connection to vogon where you create a directory and a new file and edit the file within that ssh session.  Compile, run, debug all on vogon in that ssh session. 

• Do not use any code you may have access to from earlier in this course or from other courses 

• The problem description includes all assumptions necessary to answer the problem. However, if you feel additional assumptions are or need clarification on a problem, you may ask the instructor during the exam period. 

• The program you write to solve the problem will be graded pass/fail.

• Style will not be strictly enforced on this Lab exam.


______________


The Problem.


You will write a program to determine the gas mileage for a trip given the miles driven and the gallons consumed.  The program should then calculate and print out the miles per gallon.  Lastly, the program will print a comment based on the MPG results.  


    * Develop your solution in a file named LabExam1.c there on vogon.


    * Store the miles driven and gallons used as integers.


    * Calculate the miles per gallon with two places after the decimal;


    * Use the following as comments based on the miles per gallon:


mpg >= 30             Tree hugging is the best.

30 > mpg >= 22     You've seen Inconvenient Truth.

22 > mpg >= 15     What's Global Warming??

15 > mpg                I think you just ran over Bambi with your Hummer.


    * Your prompts and output must match mine exactly.


    * You do not need to put any comments in your code.


    * You must compile on Vogon with the –Wall –ansi –pedantic flags with no warnings or errors.


 


Sample Runs:


Enter the miles driven: 300

Enter the number of gallons used: 8

Your MPG is: 37.50

Tree hugging is fun.


Enter the miles driven: 300

Enter the amount of gallons used: 25

Your MPG is: 12.00

I think you just ran over Bambi with your Hummer.