CSCI 135 Programming Exam #2 Fundamentals of Computer Science I Fall 2013

Similar documents
CSCI 135 Programming Exam #0 Fundamentals of Computer Science I Fall 2013

Car Comparison Project

Environmental Science Lab: Buying a Car.

Introduction to Computers and Engineering Problem Solving Spring 2012 Problem Set 8: Rail switching Due: 12 noon, Friday, April 27, 2012

Car Comparison Project

Manual Where Do I Get Cars Save Gas Mileage Than Automatics

Course Syllabus. Time Requirements. Course Timeline. Grading Policy. Contact Information Online classroom Instructor: Kyle Boots

PRO/CON: Should the government pay people to buy electric

Rated MPG for Confusion: Using Gas Mileage to Learn Graphing and Data Analysis

CS 374 Fall 2014 Homework 6 Due Tuesday, October 21, 2014 at noon

MINI COOPER SERVICE MANUAL

FIVE WAYS TO OPTIMIZE YOUR FLEET WITH GPS TRACKING

HONDA CIVIC MILE SERVICE EBOOK

A Guide to Reducing Grey Fleet Mileage

ebook 5 Ways to Optimize Your Fleet

Towards a Proposal for A Carbon Offset Fee for Cornell Business Travel. Bob Howarth The David R. Atkinson Professor of Ecology & Environmental Biology

Alternative Fuels for Cars. Ian D. Miller Theodore Roosevelt Elem.

EPUB » CAMRY HYBRID MANUAL EBOOK

Energy. on this world and elsewhere. Instructor: Gordon D. Cates Office: Physics 106a, Phone: (434)

NetLogo and Multi-Agent Simulation (in Introductory Computer Science)

Indicators and warning lights

Fuel efficiency Vehicle tracking Driver performance. w w w.movoly tic s.co.uk

The Funding of Pupil Transportation In North Carolina March, 2001

Smartdrive SmartIQ Pro packs

ARLINGTON COUNTY, VIRGINIA

Problem Set 3 - Solutions

2018: THE STATE OF ELECTRIC CARS IN MAINE

1999 FORD E 150 SERVICE MANUAL WIKI ANSWERS 1999 FORD E 150 PDF 1999 FORD E OWNER'S MANUAL - PDF (208 PAGES)

Vehicles. Tow. how to choose your tow vehicle CHAPTER ONE

ALAMEDA GREEN YOUR DREAM HOME SERIES

ABS DIAGRAM 97 RAV USER GUIDE E-BOOK

Column Name Type Description Year Number Year of the data. Vehicle Miles Traveled

Power Electronic Circuits

Chapter 2: Approaches to Problem Solving Lecture notes Math 1030 Section A

Car Economics Activity

Factory Manual Scion Xb 2018 READ ONLINE

Hydrogen Power Systems, Inc.

PDF / 1985 FORD E150 VAN PARTS INTERCHANGE MANUAL DOWNLOAD

Maximizing efficiency and minimizing harm. What should you be driving?

Using the NIST Tables for Accumulator Sizing James P. McAdams, PE

Vanpool Regional Administration

[E-BOOK] VAZ USER GUIDE

Toyota Auris Hybrid 2017 User Manual

E-ZPass Vehicle Descriptions

Douglas A. Stansfield President NJ Electric Auto Association President Trans Atlantic Electric Conversions LLC

FILE # SATURN SL REPAIR MANUAL DOWNLOAD

Chapter Review Problems

Belmont Drives Electric. Ride N Drive Event Saturday, March 11, 2017

1 Faculty advisor: Roland Geyer

The Problems We Deal With. From a Fleet Management Perspective.

ELECTRIC CURRENT. Name(s)

2004 Honda Civic Hybrid Manual Sedan With Cvt Transmission Problems

Plug-In. Conversions. C o r p o r a t i o n. There is a better way to get there. Plug-In Conversions PHEV-25 Owner's Manual

Investigation of Relationship between Fuel Economy and Owner Satisfaction

LETTER TO PARENTS SCIENCE NEWS. Dear Parents,

DEV498: Pattern Implementation Workshop with IBM Rational Software Architect

Gay E. Canough. OFF-GRID Design. Dr. Gay E. Canough, Master trainer. Living Off the Grid

Buying Your First Home EV Charger

User Manual. Engine and Tank Monitoring Firmware version 1.00e for Text Display YDTD-20N

Consumer Attitudes Towards Alternative Powertrains. November Mike Omotoso Senior Manager, Global Powertrain J.D. Power Automotive Forecasting

News English.com Ready-to-use ESL / EFL Lessons

Electric Vehicles in Alaska. APA Communicators Forum Sean Skaling November 8, 2018

Conventional Fuel Management Strategies That Work

Waiver Repair Cost Limit To Increase July 1st

BX Licensing System. Instructions for Request and Use of BX Software Add-Ons

Background Information. Instructions. Problem Statement. HOMEWORK INSTRUCTIONS Homework #5 Vehicle Fuel Economy Problem

DEPARTMENT OF TRANSPORTATION. National Highway Traffic Safety Administration. [Docket No. NHTSA ; Notice 2]

DOC - ADIRA PRESS BRAKE PART LIST

How Much Does It Cost To Change Car From Manual To Automatic

2010 TOYOTA PRIUS WIRING DIAGRAM 2010 TOYOTA PRIUS WIRING PDF [PDF] 2010-TOYOTA-PRIUS-ELECTRICAL-WIRING-DIAGRAMS.PDF

PDF VW CABRIO TRANSMISSION J217 MANUAL EBOOK

Mobility Fee Applications from Research Design

IMPROVING YOUR CAR S GAS MILEAGE. Page 2

Coulomb The business of Charging

USED HONDA CIVIC MANUAL TRANSMISSION FOR SALE E-BOOK

How to build a Hydraulic Ram Pump By Seth Johnson Land To House Version 1.1

Weight Conversions. 1 Ounce Pound

Ford Focus Se Manual Transmission Problems 2012 Hatchback Owners

The electrifica-on of the automobile is a foregone conclusion. - Bob Lutz, re-red Vice Chairman, GM

messages displayed with extended idle operation

Driver Vehicle Inspection Reports (DVIR) Guide

[EPUB] 2005 TOYOTA PRIUS MANUAL

Battery warranty: 8 yr, 100, miles standard on most cars.

messages displayed with extended idle operation

3. Identify four (4) air pollutants that come out of the tailpipe when a car burns gasoline?

Compressed Natural Gas Vehicles: The Road to a Cleaner Future

FILE // RAV OWNER MANUAL

Joey Nunn Corporate Government Manager, Southeast US Ken Germano Director of Fleet Management, SC Bryan Jolliff Finance Manager, SC

UNITED STATES DISTRICT COURT EASTERN DISTRICT OF MICHIGAN SOUTHERN DIVISION

Lesson 4: Fuel Costs and Fuel Economy

EJ2440 ELECTRIC TRANSPORTATION

Electric Vehicle Recharging & Solar on Strata

AREA 51 - Project Deep Water Foreman!

actsheet Car-Sharing

Driving Electric. Kristi Jacobsen Brodd Outreach Coordinator, Advanced Energy

PRO/CON: Self-driving cars could take over the road in the near future

Vetter Fuel Challenge Goals and Rules Update Updated June 14, You will make history at the 2018 Vetter Challenge.

The Hybrid and Electric Vehicles Manufacturing

[0. Title] Biased Weight Alignment Procedure for Bent Axle Alignment by Stan Pope, 4 August 2013

Fuck Uber, 30 April, 2017

Transcription:

CSCI 135 Programming Exam #2 Fundamentals of Computer Science I Fall 2013 This part of the exam is like a mini-programming assignment. You will create a program, compile it, and debug it as necessary. This part of the exam is open book and open web. You may use code from the course web site or from your past assignments. When you are done, submit all your Java source files to the Moodle exam #2 dropbox. Please double check you have submitted all the required files. You will have 100 minutes. No communication with any non-staff members is allowed. This includes all forms of real-world and electronic communication. Grading. Your program will be graded on correctness and to a lesser degree on clarity (including comments) and efficiency. You will lose a substantial number of points if your code does not compile or crashes on typical inputs. 1

Overview. You are trying to decide what car to buy. Should you buy an oh-so-manly Hummer H3? Or perhaps a plug-in Toyota Prius hybrid is a more sensible choice. To help you decide, you want to develop a program that calculates the total cost of ownership of different makes and models of cars. The total cost of ownership includes not only the original price for the vehicle, but also how much you'll likely spend on gas for the lifespan of the vehicle. To do this, you will be developing two support classes: Vehicle Represents a type of car. For example: Hummer H3, seats 5, 14.0 MPG, costs $32,300. Trip Represents a journey you commonly make in your car. For example: a trip to the grocery store, with a roundtrip distance of 2.5 miles and that occurs 52 times per year. Using these support classes, you will develop a program CarCalc. This program takes as input how long you plan to own the car, the average price of gas, and an optional make of car you are interested in. It reads a catalog of different vehicles and your yearly driving trips from a text file. From this input it prints out a total cost of ownership for each type of car. To get started, create an empty Eclipse project and extract the contents of this zip file into your project directory: http://katie.mtech.edu/classes/csci135/car.zip Part 1: Vehicle. This data type represents a particular type of car. It knows things like its make (e.g. "Toyota"), model (e.g. "Prius"), the number of passengers it can hold (e.g. 5), the average miles-per-gallon (e.g. 50.0), and the cost (e.g. $30,395). You can assume the number of passengers is always an integer, miles-per-gallon is a floating-point value, and the cost is an integer. Here is the API you are to implement for Vehicle: public class Vehicle Vehicle(String make, String model, int passengers, double mpg, int price) int getprice() double getpassengermilespergallon() String tostring() String getmakemodel() boolean issamemake(string make) double costtodrivedistance(double miles, double pricepergallon) We have provided a stub version of Vehicle.java that includes comments describing exactly what each method should do. You will need to decide on an appropriate set of instance variables. We have also provided a test main() method. Here is our output: % java Vehicle Hummer H3, 5 passengers, MPG 14.0, PMPG 70.0, $32300 Toyota Prius, 5 passengers, MPG 50.0, PMPG 250.0, $30395 Toyota Avalon, 5 passengers, MPG 25.0, PMPG 125.0, $39650 Ford E350_Super_Duty_Extended, 15 passengers, MPG 11.0, PMPG 165.0, $36545 Assuming gas costs $3.79 per gallon, cost to travel 123 miles: Hummer H3 = $33.30 Toyota Prius = $9.32 Toyota Avalon = $18.65 Ford E350_Super_Duty_Extended = $42.38 2

Toyota Prius, 5 passengers, MPG 50.0, PMPG 250.0, $30395 Toyota Avalon, 5 passengers, MPG 25.0, PMPG 125.0, $39650 Hummer H3, 5 passengers, MPG 14.0, PMPG 70.0, $32300 Part 2: Trip. This data type represents a particular car-based journey. It knows things like a friendly name for the trip (e.g. "groceries"), a round-trip distance (e.g. 27.6 miles), and the frequency you make the trip (e.g. 52 times per year). You can assume the round-trip distance is a floating-point value and the frequency is an integer value. Here is the API you are to implement for Trip: public class Trip Trip(String name, double milesroundtrip, int timesperyear) String tostring() double expenseperyear(vehicle v, double pricepergallon) We have provided a stub version of Trip.java that includes comments describing exactly what each method should do. You will need to decide on an appropriate set of instance variables. We have also provided a test main() method. Here is our output: % java Trip Hummer H3, work, round trip 10.3 miles, 250 times/year, expense per year $715.48 Toyota Prius, work, round trip 10.3 miles, 250 times/year, expense per year $200.34 Part 3: CarCalc. This program calculates the total cost of ownership of a set of vehicles. The program takes input both from command-line arguments as well as input from a file via standard input. The program requires two command-line arguments and possibly an optional third argument: Number of years Total number of years you plan to own the vehicle. For purposes of total cost of ownership, we assume at the end of this number of years the car has no remaining value. Price per gallon The average cost for a gallon of gas. We assume the price remains the same for the entire length of time you own the vehicle. Make of vehicle Optional third argument. If present, only results for vehicles matching this make (e.g. "Toyota") are returned. This matching is case insensitive, i.e. specifying "Toyota" or "toyota" amounts to the same thing. If fewer than two command-line arguments are provided, it should print a friendly help message and exit: % java CarCalc CarCalc <num years> <price per gallon> [make of vehicles] If two or more arguments are given, your program will print out information regarding these arguments: % java CarCalc 10 3.89 3

% java CarCalc 10 3.89 Toyota Results for only Toyota vehicles You can assume the first argument is always a positive integer and the second is always a positive floatingpoint value. All dollar amounts in your output should be rounded to two decimal places. Your program will read in vehicles and trips from a file via standard input. StdIn.java is in the zip file containing the stub code. Here is the provided cars_trips.txt input file: 4 Hummer H3 5 14.0 32300 Toyota Prius 5 50.0 30395 Toyota Avalon 5 25.0 39650 Ford E350_Super_Duty_Extended 15 11.0 36545 8 work 10.3 250 grocery_shopping 2.5 52 home_depot 136.8 2 ski_discovery 90.0 8 ski_big_sky 253.0 2 hike_glacier 490.0 1 bike_homestake 21.4 4 summer_road_trip 2000.0 1 The file starts with an integer saying how many total vehicles are in the file. This is followed by information for each vehicle. The vehicle information is ordered as follows: make, model, number of passengers, milesper-gallon, and cost of the vehicle. You can assume the make and model are always a single string token (e.g. "E350 Super Duty Extended" uses underscores instead of spaces in the file). After the vehicle information, another integer specifies how many trips are in the file. The information for each trip is ordered as follows: name of trip, roundtrip distance in miles, and the number of times per year the trip is made. As with the make and model, you can assume the trip name is always a single string token. Here are several example runs of our final program: % java CarCalc 10 3.89 < cars_trips.txt Hummer H3, total cost $51139.27 Toyota Prius, total cost $35670.00 Toyota Avalon, total cost $50199.99 Ford E350_Super_Duty_Extended, total cost $60522.25 % java CarCalc 10 3.89 toyota < cars_trips.txt Results for only toyota vehicles Toyota Prius, total cost $35670.00 Toyota Avalon, total cost $50199.99 4

% java CarCalc 10 3.89 bogus < cars_trips.txt Results for only bogus vehicles % java CarCalc 40 4.99 < cars_trips.txt Calculating total cost of ownership for 40 years Using price per gallon of $4.99 Hummer H3, total cost $128966.28 Toyota Prius, total cost $57461.56 Toyota Avalon, total cost $93783.12 Ford E350_Super_Duty_Extended, total cost $159574.81 % java CarCalc 1 4.99 < cars_trips.txt Calculating total cost of ownership for 1 years Using price per gallon of $4.99 Hummer H3, total cost $34716.66 Toyota Prius, total cost $31071.66 Toyota Avalon, total cost $41003.33 Ford E350_Super_Duty_Extended, total cost $39620.75 5