# lab1 - CS116 LAB 1 This lab is using material covered in...

This preview shows pages 1–4. Sign up to view the full content.

CS116 LAB 1 This lab is using material covered in CS115 and it is intended as a review. This Lab is to be started in the lab. It is due on Saturday June 5 on Blackboard time stamped by 10:00 p.m. Use EditPlus (or similar text editor, except Eclipse) to create source code. Create 3 folders Task1, Task2 and place the appropriate files in each folder depending on the task. Objectives: 1. Create a template class. 2. Use packages. 3. Create a client class for the template class. 4. Use static variables. 5. Use String pre defined class methods. 6. Use the Scanner object to receive input from the user. 7. Use Arithmetic Operations (precedence of arithmetic operators). Task 1 (1.5 point) 1. Theory 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
In Physics a vehicle that moves linearly with a speed that has constant acceleration is govern by the following formulas: Let s be the distance traveled. Let t be the time it traveled. Let a be the acceleration. Let v be the velocity at some time t (also referred to as the final velocity). s(t)=(1/2)*a*t 2 +v 0 *t+s 0 v(t)=a*t+v 0 a(t)=a (constant, therefore acceleration is not a function of time). Time is measured in seconds. v 0 is the initial velocity at time t=0 s 0 is the initial distance at time t=0 Time t=0 (indicated as t 0 ) is the time we start measuring the time (although not needed here). Velocity is measured in meters per second (m/sec). Acceleration in meters per second square (m/sec 2 ). 2. Create the template (service) class for Vehicle (1.0 point out of 1.5) Develop a class called Vehicle. The attributes (instance variables or fields as you may also call them) are: o String vehicle_name, 2
o double velocity (note: that is the velocity at a given time, also called the final velocity. It gets calculated and its value is set. See further down), o double acceleration, o double distance, o int time, o a static integer variable called vehicleID. o You will have to figure out additional variables to take care of the currentID for a particular vehicle (the current id of the vehicle object based on a static variable’s value) the initial velocity (init_v) and the initial distance (init_d). Note: The name of the vehicle must be 6 characters long. This is going to be checked by the client class in task 2 (see below). You don’t check that in this class. o There are two constructors: o Default Constructor initializes all pertinent fields to empty String or zero (8 of them). It does advance the vehicleID to a new ID value every time an object is created using the default constructor . o

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 07/06/2010 for the course CS 116 taught by Professor Koutsogiannakis during the Spring '08 term at Illinois Tech.

### Page1 / 14

lab1 - CS116 LAB 1 This lab is using material covered in...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online