SlideShare a Scribd company logo
public class RaceTrack
{
public static void main(String[] args)
{
//car 1
String car1Name = "Bob Barker Car";
float car1HandlingS = 0.30f;
float car1HandlingC = 0.62f;
float car1HandlingU = 0.1f;
float car1RaceProgress = 0;
float car1CurrentSpeed = 0;
float car1TopSpeed = 0.93f;
float car1Acceleration = 0.11f;
int car1Wins = 0;
char car1Symbol = '1';
String Racetrack = "----------U-C-S-------C---S----C--
--C--U----";
int raceLength = Racetrack.length();
boolean runningRace = true; //once someone wins we
can stop this
while (runningRace)
{
System.out.println(Racetrack);
//Car 1
//display the car
String Progress = "";
for (int i=0;i<car1RaceProgress;i++)
Progress+= " ";
System.out.println(Progress+car1Symbol);
//accelerate based on where you are on the
track
//Racetrack[(int)car1RaceProgress)]
switch
(Racetrack.charAt((int)car1RaceProgress))
{
case '-': //strait-away
if (car1CurrentSpeed < car1TopSpeed)
car1CurrentSpeed +=
car1Acceleration;
if (car1CurrentSpeed > car1TopSpeed)
car1CurrentSpeed =
car1TopSpeed;
break;
case 'S': //Chicane
if (car1CurrentSpeed <
car1TopSpeed*car1HandlingS)
car1CurrentSpeed +=
car1Acceleration;
else if (car1CurrentSpeed >
car1TopSpeed*car1HandlingS)
car1CurrentSpeed =
car1TopSpeed*car1HandlingS;
break;
case 'C': //curve
if (car1CurrentSpeed <
car1TopSpeed*car1HandlingC)
car1CurrentSpeed +=
car1Acceleration;
else if (car1CurrentSpeed >
car1TopSpeed*car1HandlingC)
car1CurrentSpeed =
car1TopSpeed*car1HandlingC;
break;
case 'U': //Hairpin
if (car1CurrentSpeed <
car1TopSpeed*car1HandlingU)
car1CurrentSpeed +=
car1Acceleration;
else if (car1CurrentSpeed >
car1TopSpeed*car1HandlingU)
car1CurrentSpeed =
car1TopSpeed*car1HandlingU;
break;
}
//increase progress
car1RaceProgress+=car1CurrentSpeed;
if (car1RaceProgress >= raceLength)
{
System.out.println(car1Name+"
wins");
car1Wins++;
runningRace=false;
}
} //end of while loop
}//end of main
}
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
DIVERSITY CONSCIOUSNESS
Social Networking
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Learning Outcomes
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
What is Social Networking?A processNodes and tiesOnline and
face-to-face
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Online and Face-to-face Networking
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
The Social Context of NetworkingStrong and Weak
TiesStrength of weak ties (Granovetter)Degree and degrees of
separationTrustTrilogy of trust
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Changing Dynamics of Social NetworkingDigital Natives
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Changing Dynamics of Social NetworkingThe Global Reach of
Social Networking
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
The Global Reach of Social Networking
Changing Dynamics of Social Networking
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Diversity Consciousness and Online Social
NetworkingAwareness and understanding
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Global connections
Diversity Consciousness and Online Social Networking
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
SkillsAssuming DiversitySeeking DiversityLeveraging
Diversity
Diversity Consciousness and Online Social Networking
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Expanding the Diversity of Online
Social Networks Maximizing Social Capital Bridging and
Bonding Education and Diverse Networks
*
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Key Diversity Issues in Online
Social Networking Identity Tourism Digital
DividesAgeGenderRace/ethnicitySocial classDisabilityGlobal
Digital Divides
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Microinsults, microassaults, and
microinvalidationsCyberbullyingDefault whiteness Impact of
online microaggressions Coping strategies
Online Microaggressions
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Benefits of Diverse Social Networks
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Cross-cultural CollaborationDiversity DiscussionsThe Wisdom
of Crowds Resource Sharing Collective Action and Social
Change Personal Empowerment
Benefits of Diverse Social Networks
Copyright © 2015, 2010, 2004 Pearson Education, Inc.
*
Case StudiesLigua
Mary
Michael
First Program
The purpose of this program will be to demonstrate your
knowledge of the basic programming fundamentals and show
that you can do so in JAVA. I will repeat that your final
submission should be a .java file of your own individual
solution (not a .class file – I am unable to grade .class files).
Your program will generate a multiple of primes table between
2 selected values. Your java program will need a class and a
main to run:
//with any necessary imports
public class MyClass {
public static void main(String args[]) {
}
}
But I will not be grading your main. Instead your job is to write
a your solution in a separate method (called a function in c++,
java calls them methods, if your wondering why it is a
fascinating google search or ask me during live sessions) name
that method primeTable. Obviously, your main method (yep, we
have to get used to method instead of function) will call this
primeTable method to run and will be required to pass in a start
and end parameters. (By the way, this is chapter 6 in
fundamentals 1…)
You do not have to read any inputs from a file or a user, you
may hard code the start and end values in main as long as you
pass them to the function (the primeTable function must take
these values in and cannot hard code them).
The only difference between methods done in JAVA and your
c++ functions are that you will need to include the word ‘static’
in your method header. The example given here prints out a
simple message but make certain it is in the scope block of your
class where the main function is located (it can be above or
below main without issue):
static void thisIsAFunction()
{
System.out.println("Hey I'm a function");
}
The actual goal of this method/ function is to take in 2 inputs (as
int’s) a start, and an end. Between these 2 values your function
will output a table of all the prime numbers between start and
end with all the multiples of them.
You will probably need to use 2 loops nested within each other
to accomplish this goal (though it can be done with 1 loop). You
may use any loop you wish but please format your table so that
it is easy to read like the example above. To do so you may use
the following function (or any other method such as decimal
format):
1
COSC 1437
Racetrack
Start with objective 1 and work on creating objects for your lab.
If you have questions or encounter errors with your code
contact the instructor by email or during live sessions for
assistance.Objective 1 (50%):
You are to take the given code which shows 1 car running a
race. Your job will be to add 5 more cars with varying stats
which should participate in the race just like the first car. In
this lab each car holds the same types of information, behaves
in the same way and only differs in their values for said
information. So the optimal solution would be to use Objects.
Create an object capable of holding the information for each
car. Also include the operations that the cars do as methods
(functions). Make certain to create a constructor that takes, as
input, adequate information to allow you to build the cars more
easily. (Due note that credit for this objective will not be earned
if you do not create and use objects for the car’s information.)
· String car2Name = "Pat Sajak Car";
· car2HandlingS = 0.45f;
· car2HandlingC = 0.65f;
· car2HandlingU = 0.3f;
· car2RaceProgress = 0;
· car2CurrentSpeed = 0;
· car2TopSpeed = 0.83f;
· car2Acceleration = 0.14f;
· car2Wins = 0;
· car2Symbol = 'P';
· String car3Name = "Alex Trebek Car";
· car3HandlingS = 0.29f;
· car3HandlingC = 0.45f;
· car3HandlingU = 0.02f;
· car3RaceProgress = 0;
· car3CurrentSpeed = 0;
· car3TopSpeed = 0.85f;
· car3Acceleration = 0.19f;
· car3Wins = 0;
· car3Symbol = 'A';
· String car4Name = "Bob Eubanks Car";
· Car4HandlingS = 0.15f;
· Car4HandlingC = 0.18f;
· Car4HandlingU = 0.05f;
· Car4RaceProgress = 0;
· Car4CurrentSpeed = 0;
· Car4TopSpeed = 0.89f;
· Car4Acceleration = 0.21f;
· Car4Wins = 0;
· Car4Symbol = 'E';
· String car5Name = "Monty Hall Car";
· Car5HandlingS = 0.18f;
· Car5HandlingC = 0.22f;
· Car5HandlingU = 0.09f;
· Car5RaceProgress = 0;
· Car5CurrentSpeed = 0;
· Car5TopSpeed = 0.93f;
· Car5Acceleration = 0.17f;
· Car5Wins = 0;
· Car5Symbol = 'M';
· String car5Name = "Richard Dawson Car";
· Car5HandlingS = 0.40f;
· Car5HandlingC = 0.5f;
· Car5HandlingU = 0.35f;
· Car5RaceProgress = 0;
· Car5CurrentSpeed = 0;
· Car5TopSpeed = 0.815f;
· Car5Acceleration = 0.19f;
· Car5Wins = 0;
· Car5Symbol = 'R';
Objective 2 (25%):
Right now the race is only being run once. I want you to adjust
the code so that the race can be run 25 times to simulate an
entire season of racing. At the end of the season I want you to
output each car’s race wins and finally display the car with the
most wins as the season champion. Objective 3 (25%):
Each race of the season should be a different race. Randomly
create racetracks prior to the start of each race. Do this by
randomly appending the four characters to a string. You can
skew the random numbers to give more straightaways or turns
depending on your preference (so long as there is a chance of
any type of racetrack being possible).
*note that some cars are better than others and 1 or 2 of them
are just awful and have no chance of winning – you do not have
to balance it in any way, if 1 car wins every time that is fine
(there will probably be some competition between at least 2 of
them but again, it is not your job to balance the win rates).
Bonus Objective (5pts):
For this lab you are allowed to hard-code the values for the race
car instances in, but for the bonus objective you should move
these to a file(s) where the information can be read into the
program.Bonus Objective 2 (5pts):
In all likelihood you created your program where each car
outputs his progress on his own individual line. For 5 additional
points adjust your program so that it draws each car on the same
line unless there are multiple cars at the exact same position (in
which case it would draw that car on the next line).

More Related Content

PPT
Abap course chapter 7 abap objects and bsp
PDF
Goal The goal of this assignment is to help students understand the.pdf
DOCX
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
PDF
AWS DeepRacer desde cero - Meetup de awsvalencia (2021/08/12)
DOCX
#include iostream#include string#include iomanip#inclu.docx
PDF
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
PDF
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
PDF
L9
Abap course chapter 7 abap objects and bsp
Goal The goal of this assignment is to help students understand the.pdf
COIT20245, 2016 Term One - Page 1 of 9 Assessment detail.docx
AWS DeepRacer desde cero - Meetup de awsvalencia (2021/08/12)
#include iostream#include string#include iomanip#inclu.docx
Assignment DIn Problem D1 we will use a file to contain the dat.pdf
This is the assignmentOBJECTIVESAfter finishing this lab, stude.pdf
L9

Similar to Public class race track {public static void main(string[] args (20)

PPTX
DOCX
cbse 12 computer science investigatory project
DOCX
cbse 12 computer science investigatory project
DOCX
Software Engineer Screening Question - OOP
PDF
C# Programming Help
PDF
VSSML16 L8. Advanced Workflows: Feature Selection, Boosting, Gradient Descent...
PDF
R, Scikit-Learn and Apache Spark ML - What difference does it make?
PDF
(7) cpp abstractions inheritance_part_ii
PPTX
Decoding Kotlin - Your guide to solving the mysterious in Kotlin - JNation2025
DOCX
Choose any multi-national organization that you would like to use .docx
PDF
(5) c sharp introduction_object_orientation_part_ii
DOCX
#include iostream #include string #include fstream std.docx
PDF
C++ Program Auto workshop service system
PPT
Lecture 2
PPTX
Loops in C# for loops while and do while loop.
DOCX
cbse 12 computer science IP
DOCX
Assignment 2 linear regression predicting car mpg
PDF
Lingo
PDF
Getting started-with-lotus-vehicle-simulation
PDF
State Monad
cbse 12 computer science investigatory project
cbse 12 computer science investigatory project
Software Engineer Screening Question - OOP
C# Programming Help
VSSML16 L8. Advanced Workflows: Feature Selection, Boosting, Gradient Descent...
R, Scikit-Learn and Apache Spark ML - What difference does it make?
(7) cpp abstractions inheritance_part_ii
Decoding Kotlin - Your guide to solving the mysterious in Kotlin - JNation2025
Choose any multi-national organization that you would like to use .docx
(5) c sharp introduction_object_orientation_part_ii
#include iostream #include string #include fstream std.docx
C++ Program Auto workshop service system
Lecture 2
Loops in C# for loops while and do while loop.
cbse 12 computer science IP
Assignment 2 linear regression predicting car mpg
Lingo
Getting started-with-lotus-vehicle-simulation
State Monad
Ad

More from YASHU40 (20)

DOCX
April 19, 2018 Course #Title MATU-203 – Introduction.docx
DOCX
APUS Assignment Rubric Undergraduate Level EXEMPLARYLEVEL4.docx
DOCX
Appropriate TopicsThe Research Report, select one of the fo.docx
DOCX
Approaches, Issues, Applications edited by Steffen.docx
DOCX
Archaic sapiens, Neandertals and the Last 10,000 YearsWhat.docx
DOCX
Applying Evidence-Based Practice”Population groups with differe.docx
DOCX
Applying Learning Theory to LifePrior to beginning work on t.docx
DOCX
Apply the Symbolic Interaction Perspective to ImmigrationD.docx
DOCX
April is a fourth grader with a language impairment, but no physical.docx
DOCX
Approximately 1000 words.Synthesizing the theories (you do not.docx
DOCX
Approaches to Forecasting Policy Outcomes Please respond to th.docx
DOCX
Apply the course concepts of the dark side of self-esteem and .docx
DOCX
Apply information from the Aquifer Case Study to answer the foll.docx
DOCX
Apply appropriate elements of the U.S. legal system and the U.S. Con.docx
DOCX
APA format Analysis of the Culture using a Culturally Competent.docx
DOCX
APA less than 10 similarityWeek 7 Discussion Question Chapter.docx
DOCX
APPLE 13Business Analytics Plan for BIAM300Author Miguel .docx
DOCX
APAless than 10 similarityWeek 4 Discussion Question .docx
DOCX
APA Style [Sources, included] single-spaced, one to two-page paper r.docx
DOCX
Application Case Siemens Builds a Strategy-Oriented HR System.docx
April 19, 2018 Course #Title MATU-203 – Introduction.docx
APUS Assignment Rubric Undergraduate Level EXEMPLARYLEVEL4.docx
Appropriate TopicsThe Research Report, select one of the fo.docx
Approaches, Issues, Applications edited by Steffen.docx
Archaic sapiens, Neandertals and the Last 10,000 YearsWhat.docx
Applying Evidence-Based Practice”Population groups with differe.docx
Applying Learning Theory to LifePrior to beginning work on t.docx
Apply the Symbolic Interaction Perspective to ImmigrationD.docx
April is a fourth grader with a language impairment, but no physical.docx
Approximately 1000 words.Synthesizing the theories (you do not.docx
Approaches to Forecasting Policy Outcomes Please respond to th.docx
Apply the course concepts of the dark side of self-esteem and .docx
Apply information from the Aquifer Case Study to answer the foll.docx
Apply appropriate elements of the U.S. legal system and the U.S. Con.docx
APA format Analysis of the Culture using a Culturally Competent.docx
APA less than 10 similarityWeek 7 Discussion Question Chapter.docx
APPLE 13Business Analytics Plan for BIAM300Author Miguel .docx
APAless than 10 similarityWeek 4 Discussion Question .docx
APA Style [Sources, included] single-spaced, one to two-page paper r.docx
Application Case Siemens Builds a Strategy-Oriented HR System.docx
Ad

Recently uploaded (20)

PPTX
How to Manage Loyalty Points in Odoo 18 Sales
PDF
High Ground Student Revision Booklet Preview
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
PDF
Landforms and landscapes data surprise preview
PDF
UTS Health Student Promotional Representative_Position Description.pdf
PPTX
How to Manage Global Discount in Odoo 18 POS
PPTX
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
PPTX
IMMUNIZATION PROGRAMME pptx
PPTX
ACUTE NASOPHARYNGITIS. pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Congenital Hypothyroidism pptx
PPTX
Software Engineering BSC DS UNIT 1 .pptx
PDF
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
PPTX
vedic maths in python:unleasing ancient wisdom with modern code
PDF
English Language Teaching from Post-.pdf
PPTX
Skill Development Program For Physiotherapy Students by SRY.pptx
PDF
Sunset Boulevard Student Revision Booklet
PDF
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
PDF
Types of Literary Text: Poetry and Prose
PPTX
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx
How to Manage Loyalty Points in Odoo 18 Sales
High Ground Student Revision Booklet Preview
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
Landforms and landscapes data surprise preview
UTS Health Student Promotional Representative_Position Description.pdf
How to Manage Global Discount in Odoo 18 POS
Nursing Management of Patients with Disorders of Ear, Nose, and Throat (ENT) ...
IMMUNIZATION PROGRAMME pptx
ACUTE NASOPHARYNGITIS. pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Congenital Hypothyroidism pptx
Software Engineering BSC DS UNIT 1 .pptx
Phylum Arthropoda: Characteristics and Classification, Entomology Lecture
vedic maths in python:unleasing ancient wisdom with modern code
English Language Teaching from Post-.pdf
Skill Development Program For Physiotherapy Students by SRY.pptx
Sunset Boulevard Student Revision Booklet
Cell Biology Basics: Cell Theory, Structure, Types, and Organelles | BS Level...
Types of Literary Text: Poetry and Prose
COMPUTERS AS DATA ANALYSIS IN PRECLINICAL DEVELOPMENT.pptx

Public class race track {public static void main(string[] args

  • 1. public class RaceTrack { public static void main(String[] args) { //car 1 String car1Name = "Bob Barker Car"; float car1HandlingS = 0.30f; float car1HandlingC = 0.62f; float car1HandlingU = 0.1f; float car1RaceProgress = 0; float car1CurrentSpeed = 0; float car1TopSpeed = 0.93f; float car1Acceleration = 0.11f; int car1Wins = 0; char car1Symbol = '1'; String Racetrack = "----------U-C-S-------C---S----C-- --C--U----"; int raceLength = Racetrack.length(); boolean runningRace = true; //once someone wins we can stop this while (runningRace) { System.out.println(Racetrack); //Car 1 //display the car String Progress = ""; for (int i=0;i<car1RaceProgress;i++) Progress+= " "; System.out.println(Progress+car1Symbol);
  • 2. //accelerate based on where you are on the track //Racetrack[(int)car1RaceProgress)] switch (Racetrack.charAt((int)car1RaceProgress)) { case '-': //strait-away if (car1CurrentSpeed < car1TopSpeed) car1CurrentSpeed += car1Acceleration; if (car1CurrentSpeed > car1TopSpeed) car1CurrentSpeed = car1TopSpeed; break; case 'S': //Chicane if (car1CurrentSpeed < car1TopSpeed*car1HandlingS) car1CurrentSpeed += car1Acceleration; else if (car1CurrentSpeed > car1TopSpeed*car1HandlingS) car1CurrentSpeed = car1TopSpeed*car1HandlingS; break; case 'C': //curve if (car1CurrentSpeed < car1TopSpeed*car1HandlingC) car1CurrentSpeed += car1Acceleration; else if (car1CurrentSpeed > car1TopSpeed*car1HandlingC) car1CurrentSpeed = car1TopSpeed*car1HandlingC; break; case 'U': //Hairpin
  • 3. if (car1CurrentSpeed < car1TopSpeed*car1HandlingU) car1CurrentSpeed += car1Acceleration; else if (car1CurrentSpeed > car1TopSpeed*car1HandlingU) car1CurrentSpeed = car1TopSpeed*car1HandlingU; break; } //increase progress car1RaceProgress+=car1CurrentSpeed; if (car1RaceProgress >= raceLength) { System.out.println(car1Name+" wins"); car1Wins++; runningRace=false; } } //end of while loop }//end of main } Copyright © 2015, 2010, 2004 Pearson Education, Inc. * DIVERSITY CONSCIOUSNESS Social Networking
  • 4. Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Learning Outcomes Copyright © 2015, 2010, 2004 Pearson Education, Inc. * What is Social Networking?A processNodes and tiesOnline and face-to-face Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Online and Face-to-face Networking Copyright © 2015, 2010, 2004 Pearson Education, Inc. * The Social Context of NetworkingStrong and Weak TiesStrength of weak ties (Granovetter)Degree and degrees of separationTrustTrilogy of trust Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Changing Dynamics of Social NetworkingDigital Natives
  • 5. Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Changing Dynamics of Social NetworkingThe Global Reach of Social Networking Copyright © 2015, 2010, 2004 Pearson Education, Inc. * The Global Reach of Social Networking Changing Dynamics of Social Networking Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Diversity Consciousness and Online Social NetworkingAwareness and understanding Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Global connections Diversity Consciousness and Online Social Networking Copyright © 2015, 2010, 2004 Pearson Education, Inc. *
  • 6. SkillsAssuming DiversitySeeking DiversityLeveraging Diversity Diversity Consciousness and Online Social Networking Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Expanding the Diversity of Online Social Networks Maximizing Social Capital Bridging and Bonding Education and Diverse Networks * Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Key Diversity Issues in Online Social Networking Identity Tourism Digital DividesAgeGenderRace/ethnicitySocial classDisabilityGlobal Digital Divides Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Microinsults, microassaults, and microinvalidationsCyberbullyingDefault whiteness Impact of online microaggressions Coping strategies Online Microaggressions
  • 7. Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Benefits of Diverse Social Networks Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Cross-cultural CollaborationDiversity DiscussionsThe Wisdom of Crowds Resource Sharing Collective Action and Social Change Personal Empowerment Benefits of Diverse Social Networks Copyright © 2015, 2010, 2004 Pearson Education, Inc. * Case StudiesLigua Mary Michael First Program The purpose of this program will be to demonstrate your knowledge of the basic programming fundamentals and show that you can do so in JAVA. I will repeat that your final submission should be a .java file of your own individual solution (not a .class file – I am unable to grade .class files). Your program will generate a multiple of primes table between 2 selected values. Your java program will need a class and a main to run: //with any necessary imports public class MyClass {
  • 8. public static void main(String args[]) { } } But I will not be grading your main. Instead your job is to write a your solution in a separate method (called a function in c++, java calls them methods, if your wondering why it is a fascinating google search or ask me during live sessions) name that method primeTable. Obviously, your main method (yep, we have to get used to method instead of function) will call this primeTable method to run and will be required to pass in a start and end parameters. (By the way, this is chapter 6 in fundamentals 1…) You do not have to read any inputs from a file or a user, you may hard code the start and end values in main as long as you pass them to the function (the primeTable function must take these values in and cannot hard code them). The only difference between methods done in JAVA and your c++ functions are that you will need to include the word ‘static’ in your method header. The example given here prints out a simple message but make certain it is in the scope block of your class where the main function is located (it can be above or below main without issue): static void thisIsAFunction() { System.out.println("Hey I'm a function"); } The actual goal of this method/ function is to take in 2 inputs (as int’s) a start, and an end. Between these 2 values your function will output a table of all the prime numbers between start and end with all the multiples of them.
  • 9. You will probably need to use 2 loops nested within each other to accomplish this goal (though it can be done with 1 loop). You may use any loop you wish but please format your table so that it is easy to read like the example above. To do so you may use the following function (or any other method such as decimal format): 1 COSC 1437 Racetrack Start with objective 1 and work on creating objects for your lab. If you have questions or encounter errors with your code contact the instructor by email or during live sessions for assistance.Objective 1 (50%): You are to take the given code which shows 1 car running a race. Your job will be to add 5 more cars with varying stats which should participate in the race just like the first car. In this lab each car holds the same types of information, behaves in the same way and only differs in their values for said information. So the optimal solution would be to use Objects. Create an object capable of holding the information for each car. Also include the operations that the cars do as methods (functions). Make certain to create a constructor that takes, as input, adequate information to allow you to build the cars more easily. (Due note that credit for this objective will not be earned if you do not create and use objects for the car’s information.) · String car2Name = "Pat Sajak Car"; · car2HandlingS = 0.45f;
  • 10. · car2HandlingC = 0.65f; · car2HandlingU = 0.3f; · car2RaceProgress = 0; · car2CurrentSpeed = 0; · car2TopSpeed = 0.83f; · car2Acceleration = 0.14f; · car2Wins = 0; · car2Symbol = 'P'; · String car3Name = "Alex Trebek Car"; · car3HandlingS = 0.29f; · car3HandlingC = 0.45f; · car3HandlingU = 0.02f; · car3RaceProgress = 0; · car3CurrentSpeed = 0; · car3TopSpeed = 0.85f; · car3Acceleration = 0.19f; · car3Wins = 0; · car3Symbol = 'A'; · String car4Name = "Bob Eubanks Car"; · Car4HandlingS = 0.15f; · Car4HandlingC = 0.18f; · Car4HandlingU = 0.05f; · Car4RaceProgress = 0; · Car4CurrentSpeed = 0; · Car4TopSpeed = 0.89f; · Car4Acceleration = 0.21f; · Car4Wins = 0; · Car4Symbol = 'E'; · String car5Name = "Monty Hall Car"; · Car5HandlingS = 0.18f; · Car5HandlingC = 0.22f; · Car5HandlingU = 0.09f; · Car5RaceProgress = 0;
  • 11. · Car5CurrentSpeed = 0; · Car5TopSpeed = 0.93f; · Car5Acceleration = 0.17f; · Car5Wins = 0; · Car5Symbol = 'M'; · String car5Name = "Richard Dawson Car"; · Car5HandlingS = 0.40f; · Car5HandlingC = 0.5f; · Car5HandlingU = 0.35f; · Car5RaceProgress = 0; · Car5CurrentSpeed = 0; · Car5TopSpeed = 0.815f; · Car5Acceleration = 0.19f; · Car5Wins = 0; · Car5Symbol = 'R'; Objective 2 (25%): Right now the race is only being run once. I want you to adjust the code so that the race can be run 25 times to simulate an entire season of racing. At the end of the season I want you to output each car’s race wins and finally display the car with the most wins as the season champion. Objective 3 (25%): Each race of the season should be a different race. Randomly create racetracks prior to the start of each race. Do this by randomly appending the four characters to a string. You can skew the random numbers to give more straightaways or turns depending on your preference (so long as there is a chance of any type of racetrack being possible). *note that some cars are better than others and 1 or 2 of them are just awful and have no chance of winning – you do not have to balance it in any way, if 1 car wins every time that is fine (there will probably be some competition between at least 2 of them but again, it is not your job to balance the win rates). Bonus Objective (5pts): For this lab you are allowed to hard-code the values for the race car instances in, but for the bonus objective you should move
  • 12. these to a file(s) where the information can be read into the program.Bonus Objective 2 (5pts): In all likelihood you created your program where each car outputs his progress on his own individual line. For 5 additional points adjust your program so that it draws each car on the same line unless there are multiple cars at the exact same position (in which case it would draw that car on the next line).