This action might not be possible to undo. Are you sure you want to continue?

BooksAudiobooksComicsSheet Music### Categories

### Categories

### Categories

### Publishers

Scribd Selects Books

Hand-picked favorites from

our editors

our editors

Scribd Selects Audiobooks

Hand-picked favorites from

our editors

our editors

Scribd Selects Comics

Hand-picked favorites from

our editors

our editors

Scribd Selects Sheet Music

Hand-picked favorites from

our editors

our editors

Top Books

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Audiobooks

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Comics

What's trending, bestsellers,

award-winners & more

award-winners & more

Top Sheet Music

What's trending, bestsellers,

award-winners & more

award-winners & more

P. 1

Program 1|Views: 17|Likes: 1

Published by kokobilizarizone

See more

See less

https://www.scribd.com/doc/37316738/Program-1

09/12/2010

text

original

Notes 1. Please read the notes on Dev C++ and WebCourses provided with Lab #0 if you didn’t get a chance to do that lab. 2. In this assignment, you are required to write three programs. Objectives 1. To give students practice at typing in, compiling and running simple programs. 2. To learn how to read in input from the user. 3. To learn how to use assignment statements and arithmetic expressions. References Textbook: Sections 2, 3 Notes: Lectures 2, 3, 4

Problem A: Calculating Fuel Economy With the recently increasing gas prices, car manufacturers have been touting their vehicles' fuel economy. Cars, such as the Toyota Prius tell their drivers what their fuel efficiency for five minute time intervals. In this program, you will perform a calculation similar to what the Prius computer does, to calculate fuel economy (in miles per gallon) for a given duration of time. In particular, your program will ask the user to enter the following information: the interval of time the car has traveled (in minutes), the average speed of the car during that interval of time (in miles per hour), and the amount of gasoline that has been consumed in the interval (in gallons). Your program will read in this information and then output the fuel efficiency of the user's car for that portion of the trip, to two decimal places, in miles per gallon. Input Specification 1. The number of minutes the car has traveled will be an integer. 2. The speed of the car will be a positive real number. 3. The gasoline consumed will be a positive real number. Output Specification Output the fuel efficiency in miles per gallon to two decimal places. Your output should follow the format below, where XX.XX is the desired fuel efficiency. Your car averaged XX.XX miles per gallon. Output Sample Below is one sample output of running the program. Note that this sample is NOT a comprehensive test. You should test your program with different data than is shown here based on the specifications given above. In the sample run below, for clarity and ease of

the user input is given in italics while the program output is in bold.) . (When you run your own program. no italics or bold will appear.2 reading.

14159 for the purposes of this problem. for clarity and ease of reading. In the sample run below. Please define π to be 3.87 miles. in miles. the user input is given in italics while the program output is in bold.00 miles. Your car traveled XX. in inches? 15 How many revolutions did your car's tires make? 10000 Your car traveled 14. Follow the format below. Input Specification 1. Instead. Note: this portion of the problem involves defining a constant for π and looking up information (on-line) about converting between inches and miles. In this problem. Sample Run #2 What is the radius of your tires. Note that these samples are NOT a comprehensive test.XX is the distance traveled. You should test your program with different data than is shown here based on the specifications given above. 2. to two decimal places. to two decimal places. Output Samples Below are two sample outputs of running the program. The radius of the tires will be a positive real number in inches. in inches? 16 How many revolutions did your car's tires make? 3151 Your car traveled 5. you will ask the user for these two pieces of information and then calculate the distance the car traveled. the calculation is made by using the radius of the tires and counting the number of revolutions the tires make. The number of revolutions of the tires will be a positive integer. Sample Run #1 What is the radius of your tires. Problem B: Calculating Distance Traveled The manner in which distance traveled is typically calculated by a car such as the Prius is not by using the average speed and the time traveled.3 Sample Run #1 How many minutes did you drive? 30 What was the average speed of the car during that time? 40 How many gallons of gas did your car use? 0.XX miles. Output Specification Output the number of miles the car has traveled based on the given information. where XX.00 miles per gallon.8 Your car averaged 25. .

in inches? 15 How many revolutions did your car's tires make? 10000 How many gallons of gas did your car use? 0. Sample Run #2 What is the radius of your tires. in gallons. Output Specification Output the fuel efficiency in miles per gallon to two decimal places. Output Samples Below are two sample outputs of running the program. the user input is given in italics while the program output is in bold.75 Your car averaged 19. . This time. 3. Your output should follow the format below. the car used during that same time period. Your program should read in this information and then output the fuel efficiency of the car in miles per gallon. you will prompt the user for the following information: the radius of the car's tires.11 Your car averaged 45.45 miles per gallon. in inches? 16 How many revolutions did your car's tires make? 3151 How many gallons of gas did your car use? 0. The radius of the car's tires will be a positive real number in inches. for clarity and ease of reading. The number of revolutions the car's tires make will be a positive integer. you will solve the original problem. You should test your program with different data than is shown here based on the specifications given above. the car uses will be a positive real number. Sample Run #1 What is the radius of your tires. Note that these samples are NOT a comprehensive test. where XX.4 Problem C: Revised Fuel Economy Calculation Using your solutions to problems A and B. with different input data.83 miles per gallon.XX is the desired fuel efficiency. and the amount of gas (in gallons). 2.XX miles per gallon. Input Specification 1. In the sample run below. The amount of gas. Your car averaged XX. the number of revolutions the car's tires went through in a given time period.

Restrictions Although you may use other compilers. course number. Also. Each of your three programs should include a header comment with the following information: your name. your program must compile and run using Dev C++. if your programming style is poor or your use of white space is poor. Even if you have a plan and your program works perfectly.c for your solution to problem C All files are to be submitted over WebCourses. you could get 10% or 15% deducted from your grade. section number. . Grading Details Your programs will be graded upon the following criteria: 1) Your correctness 2) Your programming style and use of white space.c for your solution to problem B 3) mpgfinal. assignment title. the maximum credit you will receive is 50%.c.5 Deliverables Three source files: 1) mpg. make sure you include comments throughout your code describing the major steps in solving the problem. and date. for your solution to problem A 2) distance. 3) Compatibility to Dev C++ (in Windows). If your program does not compile in this environment.

Syllabus EET 4190C -Digital Signal Processing - CRN 16952 - Fall 2012

Syllabus ETP 4240C - Power Electronics - CRN 26615 - Spring 2014

Syllabus EET 3732 - Linear Control Systems - CRN 25439 - Spring 2010

Syllabus EET 3732 - Linear Control Systems - CRN 25439 - Spring 2014

Syllabus EET 3329C -Communication Systems - CRN 16951 - Fall 2012

TCP Client_Server PowerPoint

Advanced Engineering Mathematics 8Ed - Erwin Kreyszig - Solutions Manual

EET 2325C - 14136_F12

A Tear and a Smile--Kahlil Gibran

- Read and print without ads
- Download to keep your version
- Edit, email or read offline

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

CANCEL

OK

You've been reading!

NO, THANKS

OK

scribd

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->