Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out
Get this document free

CS115 Project Assignment NAME PARTNER'S NAME Due Date December

VIEWS: 7 PAGES: 10

									                                      CS115
                              Project Assignment
NAME:
PARTNER’S NAME:
Due Date: December 1, 2010 by 10:00 p.m. on Blackboard. Must be
presented to the instructor by every team (by both members of a team if a team
has two persons) on Dec 1 st or before. Must also be uploaded on blackboard by
both partners!!!

This document with the names must also be included in the uploaded files.

Grade: 8 points ( 2 for Design part / 6 for the code and correct output).

Instructions:          zip all files and name it firstName_lastName_Project.zip then upload
                       on Blackboard.

Objective:     Design multiple classes that communicate with each other (called message
passing).Use arrays of primitive data types and arrays of objects. Use Math class methods. Use
design concepts. You must design some of the classes in writing below as asked. Use Java
API to decide how to use a library class and its methods.

Groups: This project can be worked on in groups of two or individually. You must declare
your partner by November 08 if you are going to have a partner.

In Class Discussions on Project: There would be a number of in class discussions on the project
that will provide clarifications, hints and other information. Feel free to come and see me in my
office for help. Don’t hesitate to also contact the TAs for help.

In addition, I am planning a special session on Monday November 22 at 5:00 p.m. (room 108).
Indicate before then, if you are planning to attend, by sending me an email. In this special session
I would entertain questions and provide hints.

Description:

                                                 1
We are going to simulate a game:

        This project is a game based on a lottery used by a car manufacturer to award cars to
people as a marketing promotion. The car manufacturer is going to give away 8 vehicles to
people who have filled out a form to participate in the promotion. Based on the information
provided by each person, a file is created with information about the participants. Thirty people
participating in the promotion are recorded in a file called People.txt. Each person is assigned a
lottery number sequentially from 1 to 30.

         The vehicles to be awarded are recorded in a file called Vehicle.txt. A number is drawn 8
times and each time a car is awarded to the person whose lottery number matches the number
drawn. After the lottery, the 8 winners of the 8 cars then race their cars in a speedway. The car
that arrives first to the finishing line wins for its driver the top prize of $1,000,000.00. Everyone
gets to keep the car they drove.

       Vehicles Information
        The vehicles to be awarded are of 4 different types . The first type is Truck, the second
is SUV, the third is Van and the fourth is RaceCar. There are 8 Vehicles available of all types
(two per type) in the Vehicle.txt file. The information in the file Vehicle.txt gives the type and
the drive attributes for each vehicle to be awarded, as well as the price of the vehicle. The
attribute drive can have one of the following literal values: “frontwheel” “rearwheel”,
“either”. Notice that the quotation marks should not be typed in the file. The attributes
values of each vehicle are separated by commas from each other. There is one line typed for each
vehicle in the text file (total of 8 lines). Prepare the text file Vehicle.txt with the 8 lines of
vehicles’ information with values chosen by you. You can assign your own price to each vehicle.
For example:


       Truck, either, 22000
       RaceCar, frontwheel, 33500
       People Information
        There is a file that has the information on the participating people. The file contains
information on first name ,last name, social security number , and an attribute that represents
the lottery number issued for each person, separated by comma. The lottery number held by
each person is sequential starting from 1 for the first person and ending with 30 for the last
person. The information is written in the file as one line per person. There are 30 people
available in the file. Prepare the text file People.txt by entering the information required as
chosen by you. Make sure that at least 6 people out of 30 have the same social security number,
the rest should be different. For example:
       Helen,Doe,123456,1

                                                  2
       Maria,Doe1,34567,2
       Program Sequence
        Your program reads the People.txt and Vehicle.txt files and extracts the data. The game is
as follows:
        The car manufacturer gives away a vehicle based on a drawn number (like a lottery) that
identifies the lottery number held by a customer. The number is drawn using uniform
probability. There are 8 unique numbers to be drawn (one for each vehicle to be given away).
         A winner is declared if the drawn number (called lottery ticket) matches the lottery
number of one of the customers listed in the People.txt file. Since there are more lottery numbers
issued (30) than cars (8), some lottery numbers are not winning numbers and the person is
notified that he/she lost.
       When a winner is found the person is checked against the previous winners in order to
eliminate double entries in the promotion. Two participants are declared equal if they have the
same social security number. If a winner has the same social security number as a previous
winner , he/she is disqualified and another number is drawn.
        Also, if the same number is drawn more than once, the number drawn the second time is
thrown out and a new number is drawn in its place (in other words a person can’t win more than
once). Each car has a unique id that is being assigned when the car is awarded. The id s run from
1 to 8.
        Next, the race takes place. Each vehicle is assigned an acceleration randomly, using
uniform probability distribution. Accelerations vary from 1 to 20 feet per second square. In
case the same maximum acceleration value is assigned to more than one car, the first car that
received that value wins. It is assumed that the timing of each car starts from the time they
achieve the assigned acceleration. From there on, the cars speed with a constant acceleration.

       The winning car is the one that covers a distance of 50,000 feet in the shortest time.


Uniform Acceleration Motion Theory
When an object moves with constant acceleration the following formulas apply.

       Let s be the distance traveled.
       Let t be the time it traveled.
       Let a be the acceleration.
       Let v be the velocity.
       s(t)=(1/2)*a*t2+v0*t+s0
       v(t)=a*t+v0
       a(t)=a      (constant, therefore acceleration is not a function of time).

                                                3
       Time is measured in seconds.
       v0 is the initial velocity at time t=0. In our case the initial velocity is zero.
       S0 is the initial distance at time t-=0. In our case the initial distance is also zero.
       Therefore the formulas are reduced to:
            1. s(t)=(1/2)*a*t2
            2. v(t)=a*t

       Use the above two formulas.
       In our case we know the value of s(t) in formula 1 as being 50,000 feet. We solve
       formula 1 for the variable t in order to calculate the time to travel a certain distance
       with a specific acceleration:

       t=square_root(2*a*S) / a           or      t=square_root(2*s/a)

       The second formula (identified as #2 above) calculates the final velocity of the vehicle
       at the end of time t.

Generating numbers with a uniform probability

Numbers can be generated based on a uniform probability of occurrence (in other words the
probability of a number to occur is the same for all numbers in the range). The example formula
below generates numbers in the range 1 to 20 with equal probability for each number.

int num=(int)(1+Math.random()*(20));

where num is the integer that will be generated randomly. The numbers 1 and 20 define the
range of the random numbers to be generated.



Program Input:
       The file with the people information called People.txt, which contains information on 30
       people.
       The file with the Vehicles information called Vehicles.txt, it contains information on 8
       Vehicles.


Program Output:
The program outputs the following information:
                                                   4
              For each winner: The first and last name, the social security number their lottery
               ticket number, the type of the car won, the drive type of the car won, the id of the
               car won, the price of the car won.

              The first and last name of the people that lost and did not win anything.

              Output the name of the cheaters, if any. Cheaters are people who had double
               entries based on their social security number. If no cheaters were found indicate
               so.

              The name of the person that won the race. The acceleration value assigned to
               his/her vehicle, the id of the vehicle, the time it took to travel the distance and the
               final velocity of that vehicle.

              The sequence at which the cars arrived at the finishing line. For each car list it id
               number and its acceleration.



TASKS
Perform the following tasks
   A. DESIGN (due December 1)- 2 points
       Using a WORD file describe the following:
At the top of the document list the name of the person (s) (maximum 2) who worked on this
project!!!
   1. List the classes that need to be designed. If it is a template (service) class, list the
      attributes (fields) of the class including their data types and if they are static or not, the
      accessor/mutator methods and any other methods that you would include.
       For each of the methods in that class, include the returned value, if any, and the
       arguments received (if any) and if the method is static or not.
       For each class give a short description of its functionality (contribution) in the overall
       project. Identify the class that has the main method.
   2. Next give a summary of library classes that are going to be used in your program.
      Provide the package name, the name of the class and the particular method that it is going
      to be used. Indicate if the method is static or not.

   3. Test Plan
       Give a table of tests that you would want to perform in order in order to validate your
       program. For each test identify the type of input, the expected output. Notice that the
       inputs for the tests can be different than the full 2 input files. They can be, for instance
                                                  5
       files with 1 line of input information, as an example, or 2 lines. You could also include
       System.out.println statements in your code in order to verify the values of various
       variables as the execution of your code progresses. You could indicate the expected
       results of those variable sin your tests.

   B. SOURCE CODE (due December 1)- 6 points
           1. Provide the source code files.
       Each source code file must begin with the names of the people that worked on the
       project as a comment.
           2. Provide the compiled files (.class files)
           3. Provide the two input text files.



SUBMISSION

Submit the Design Word file (Task A) on Blackboard by December 2, 10:00 p.m. Zip the file and
name the zipped file with the first and last name of one of the people in the group. Upload to
assignment: Project Design

Submit the Code files (Task B) by zipping the files and naming the zipped file with the first and
last name of one of the people in the group by December 7 , 10:00 p.m..



Sample output of the program:
The following is an output when the program was run. Different numbers get generated every time we
run the program. The reason for that of course has to do with the usage of the random method of the
Math class.



C:\CS115\FALL2009\Project\ProjectSolution>java VehiclesLottery



The number drawn is 7

The number drawn is 15

The number drawn is 5

                                                 6
The number drawn is 8

The number drawn is 10

This person has won already under a different name (person # 10 and person # 5 have the same ss#)

The number drawn is 19

This person has won already under a different name(person # 19 and person # 5 have the same ss#)

The number drawn is 12

The number drawn is 20

The number drawn is 19

This person has won already under a different name( person # 19 and person # 5 have the same ss#)

The number drawn is 14

The number drawn is 25

THE WINNERS ARE:-------------------------------

First Name= Frank Last Name= Doe6 Social Sec= 2987 Lottery number= 7 id= 30 Person ID=7and the
winning status is true

The vehicle id=1 The drive is: frontwheel The type is: Truck The price is: 23000

the acceleration is: 0 The final velocity is 0.0 The time was: 0.0

-----------------------

First Name= Mary Last Name= Doe14 Social Sec= 5677 Lottery number= 15 id= 30 Person ID=15and the
winning status is true

The vehicle id=2 The drive is: frontwheel The type is: SUV The price is: 21000 the acceleration is: 0 The
final velocity is 0.0 The time was: 0.0

-----------------------

First Name= Maria Last Name= Doe4 Social Sec= 2988 Lottery number= 5 id= 30 Person ID=5and the
winning status is true

The vehicle id=3 The drive is: either The type is: VAN The price is: 19650 the acceleration is: 0 The final
velocity is 0.0 The time was: 0.0

-----------------------
                                                      7
First Name= Anita Last Name= Doe7 Social Sec= 1934 Lottery number= 8 id= 30 Person ID=8and the
winning status is true

The vehicle id=4 The drive is: rearwheel The type is: RaceCar The price is: 35300 the acceleration is: 0
The final velocity is 0.0 The time was: 0.0

-----------------------

First Name= Salvador Last Name= Doe11 Social Sec= 4537 Lottery number= 12 id= 30 Person ID=12and
the winning status is true

The vehicle id=5 The drive is: rearwheel The type is: Truck The price is: 15000 the acceleration is: 0 The
final velocity is 0.0 The time was: 0.0

-----------------------

First Name= Anita Last Name= Doe19 Social Sec= 1935 Lottery number= 20 id= 30 Person ID=20and the
winning status is true

The vehicle id=6 The drive is: either The type is: VAN The price is: 22000 the acceleration is: 0 The final
velocity is 0.0 The time was: 0.0

-----------------------

First Name= James Last Name= Doe13 Social Sec= 2346 Lottery number= 14 id= 30 Person ID=14and the
winning status is true

The vehicle id=7 The drive is: either The type is: RaceCar The price is: 26900 the acceleration is: 0 The
final velocity is 0.0 The time was: 0.0

-----------------------

First Name= John Last Name= Doe24 Social Sec= 2234 Lottery number= 25 id= 30 Person ID=25and the
winning status is true

The vehicle id=8 The drive is: frontwheel The type is: SUV The price is: 25400 the acceleration is: 0 The
final velocity is 0.0 The time was: 0.0

-----------------------

THE LOOSERS ARE:----------------------

John Doe

James Doe1

Mary Doe2
                                                     8
Helen Doe3

George Doe5

Dave Doe8

Shara Doe9

Sylvester Doe10

John Doe12

Helen Doe15

Maria Doe16

George Doe17

Frank Doe18

Dave Doe20

Shara Doe21

Sylvester Doe22

Salvador Doe23

James Doe25

Mary Doe26

Helen Doe27

Maria Doe28

George Doe29

ASSIGN RANDOM ACCELERATIONS TO EACH CAR

the acceleration assigned for car id# 1 is: 17

the acceleration assigned for car id# 2 is: 3

the acceleration assigned for car id# 3 is: 14

the acceleration assigned for car id# 4 is: 4

the acceleration assigned for car id# 5 is: 13

                                                 9
the acceleration assigned for car id# 6 is: 18

the acceleration assigned for car id# 7 is: 7

the acceleration assigned for car id# 8 is: 7

THE RACE STARTS------------------

The winning time is: 74.53

The winning driver is:First Name= Anita Last Name= Doe19 Social Sec= 1935 Lottery number= 20 id= 30
Person ID=20and the winning status is true

The winning car is: The vehicle id=6 The drive is: either The type is: VAN Theprice is: 22000the
acceleration is: 18 The final velocity is 1341.5737027834139

The time was: 74.53187237685633 The acceleration was: 18 and the final velocity was:
1341.5737027834139




Copyright: George koutsogiannakis, Illinois Institute of
Technology- Fall 2010




                                                    10

								
To top