Please help me write the following code in java the instructions are here-
Using the following table:
|
Time (seconds) |
Athlete name |
Nationality |
Date |
Location |
|
9.58 |
Usain Bolt |
Jamaica |
16 August 2009 |
Berlin |
|
9.69 |
Tyson Gray |
USA |
20 September 2009 |
Shanghai |
|
9.69 |
Yohan Blake |
Jamaica |
23 August 2012 |
Lausanne |
|
9.72 |
Asafa Powell |
Jamaica |
2 September 2008 |
Lausanne |
|
9.78 |
Nesta Carter |
Jamaica |
29 August 2010 |
Rieti |
|
9.79 |
Maurice Greene |
USA |
16 June 1999 |
Athens |
|
9.79 |
Justin Gatlin |
USA |
5 August 2012 |
London |
|
9.80 |
Steve Mullings |
Jamaica |
4 June 2011 |
Eugene |
|
9.84 |
Donovan Bailey |
Canada |
27 July 1996 |
Atlanta |
|
9.84 |
Bruny Surin |
Canada |
22 August 1999 |
Seville |
1.) Create an array list called runner and add the items
above.
2.) Create a method called printRunners() that traverses through
the array and prints out each element.
3.) Create a method called updateLocation, to add the country to
the city ran (Ex. London, England). Print the list.
4.) Create a method called InsertName(), add Florence
Griffith-Joyner to the list. She ran 10.49 seconds on 16 July 1988,
in Indianapolis, Indiana. She was born in the USA. Print the
list.
5.) Create a method called replaceName() and replace Bruny Surin
with Carl Lewis. He ran 9.86 seconds on 23 August 1991, in Tokyo,
Japan. He was born in the USA. Print the list.
thanks for the question, here is the code in java, let me know in case you need any changes or have questions.
thanks a lot !
==================================================================================
import
com.sun.org.apache.bcel.internal.generic.ALOAD;
import java.util.ArrayList;
public class Runner {
private double
time;
private String
atheleteName;
private String
nationality;
private String
date;
private String
location;
public
Runner(double time, String atheleteName, String
nationality, String date, String location) {
this.time = time;
this.atheleteName =
atheleteName;
this.nationality =
nationality;
this.date = date;
this.location = location;
}
public double getTime() {
return
time;
}
public String getAtheleteName()
{
return
atheleteName;
}
public String getNationality()
{
return
nationality;
}
public String getDate() {
return
date;
}
public String getLocation()
{
return
location;
}
public void
setTime(double time) {
this.time = time;
}
public void
setAtheleteName(String atheleteName) {
this.atheleteName =
atheleteName;
}
public void
setNationality(String nationality) {
this.nationality =
nationality;
}
public void setDate(String
date) {
this.date = date;
}
public void setLocation(String
location) {
this.location = location;
}
@Override
public String toString()
{
return
"Time: " + time +
" secs , Athelete Name: " +
atheleteName +
",
Nationality: " + nationality +
", Date: " + date +
", Location: " + location;
}
public static void
main(String[] args) {
ArrayList<Runner>
runners = new ArrayList<>();
// 1
runners.add(new
Runner(9.58,"Usain
Bolt","Jamaica","16 August
2009","Berlin"));
runners.add(new Runner(9.69,"Tyson
Gray","USA","20 September
2009","Shanghai"));
runners.add(new Runner(9.69,"Yohan
Blake","Jamaica","23 August
2012","Lausanne"));
runners.add(new Runner(9.72,"Asafa
Powell","Jamaica","2 September
2008","Lausanne"));
runners.add(new Runner(9.78,"Nesta
Carter","Jamaica","29 August
2010","Rieti"));
runners.add(new Runner(9.79,"Maurice
Greene","USA","16 June
1999","Athens"));
runners.add(new Runner(9.79,"Justin
Gatlin","USA","5 August
2012","London"));
runners.add(new Runner(9.80,"Steve
Mullings","Jamaica","4 June
2011","Eugene"));
runners.add(new Runner(9.84,"Donovan
Bailey","Canada","27 July
1996","Atlanta"));
runners.add(new Runner(9.84,"Bruny
Surin","Canada","22 August
1999","Seville"));
printRunners(runners);
updateLocation(runners);
printRunners(runners);
insertName(runners,10.49,"Florence Griffith
Joyner","USA","!6 July
1988","Indianapolis, Indiana");
printRunners(runners);
replaceName(runners,"Bruny
Surin","Carl
Lewis",9.86,"USA","23 August
1991","Tokyo, Japan");
printRunners(runners);
}
// 2
public static void
printRunners(ArrayList<Runner> runners){
for(Runner runner:runners)
System.out.println(runner);
System.out.println("====================================================================================================================================");
}
//3
public static void
updateLocation(ArrayList<Runner> runners){
for(Runner runner : runners){
if(runner.getLocation().equalsIgnoreCase("Berlin")){
runner.setLocation("Berlin, Germany");
}else
if(runner.getLocation().equalsIgnoreCase("Shanghai")){
runner.setLocation("Shanghai, China");
}else
if(runner.getLocation().equalsIgnoreCase("London")){
runner.setLocation("London, England");
}else
if(runner.getLocation().equalsIgnoreCase("Athens")){
runner.setLocation("Athens, Greece");
} else
if(runner.getLocation().equalsIgnoreCase("Eugene")){
runner.setLocation("Eugene, South Africa");
} else
if(runner.getLocation().equalsIgnoreCase("Seville")){
runner.setLocation("Seville, France");
}else
if(runner.getLocation().equalsIgnoreCase("Lausanne")){
runner.setLocation("Lausanne, Spain");
}else
if(runner.getLocation().equalsIgnoreCase("Rieti")){
runner.setLocation("Rieti, Australia");
}
}
}
// 4
public static void
insertName(ArrayList<Runner> runners, double
time, String atheleteName, String nationality, String date, String
location){
Runner runner =
new
Runner(time,atheleteName,nationality,date,location);
runners.add(runner);
}
// 5
public static void
replaceName(ArrayList<Runner> runners, String searchName,
String replaceName, double time, String
nationality, String date, String location){
for(Runner runner: runners){
if(runner.getAtheleteName().equalsIgnoreCase(searchName)){
runner.setTime(time);
runner.setAtheleteName(replaceName);
runner.setNationality(nationality);
runner.setDate(date);
runner.setLocation(location);
}
}
}
}
Please help me write the following code in java the instructions are here- Using the following...
Please try to write the code with Project 1,2 and 3 in
mind. And use java language, thank you very much.
Create an Edit Menu in your GUI
Add a second menu to the GUI called Edit which will have one
menu item called Search. Clicking on search should prompt the user
using a JOptionPane input dialog to enter a car make. The GUI
should then display only cars of that make. You will need to write
a second menu...
Please please help me with this code please Purpose: To learn the basics of linked lists You are to implement 2 classes, Scene and Movie. Note: Please dont use inbuild linkedList methods and functions The Scene class has the following fields and methods: p rivate String event private Scene nextScene Public Scene(String event) - A constructor that creates a Scene object with the event set and nextScene set to null Public Scene(String event, Scene next) - A constructor that creates...
Please I need help with the following questions in JAVA programming language. Please comment the code to help me understand, thanks. Exercise 1: Inheritance 1. Firstly, create and compile a simple class called Parent. Give it the following behaviour: a. A default constructor that does nothing other than print out “Parent default constructor” using System.out b. A single method called getMessage which returns a String, e.g. “Parent message” 2. Next, create and compile a class called Child. Give it the...
Can someone please help me with the following java assignment. So in this assignment you will begin with the starterProject I provide and then add to it. I am also asking that before you begin you really look at the starterProject because this is the object-oriented basics. The starterProject is the exact same as the ClassClockExample.zip in Module 5. I’ve also done this using a clock because it is something that you already know how it works. Remember that OOD and OOP is...
can someone please double check my code here are the requirements please help me fulfill the requirements Using the material in the textbook (NumberList) as a sample, design your own dynamic linked list class (using pointers) to hold a series of capital letters. The class should have the following member functions: append, insert (at a specific position, return -1 if that position doesn't exist), delete (at a specific position, return -1 if that position doesn't exist), print, reverse (which rearranges...
Can you please help me with creating this Java Code using the following pseudocode? Make Change Calculator (100 points + 5 ex.cr.) 2019 In this program (closely related to the change calculator done as the prior assignment) you will make “change for a dollar” using the most efficient set of coins possible. In Part A you will give the fewest quarters, dimes, nickels, and pennies possible (i.e., without regard to any ‘limits’ on coin counts), but in Part B you...
In C++: Please help me correct this code .... All parts with (FIX ME) #include <algorithm> #include <climits> #include <iostream> #include <string> // atoi #include <time.h> #include "CSVparser.hpp" using namespace std; //============================================================================ // Global definitions visible to all methods and classes //============================================================================ const unsigned int DEFAULT_SIZE = 179; // forward declarations double strToDouble(string str, char ch); // define a structure to hold bid information struct Bid { string bidId; // unique identifier string title; string fund; double amount; Bid() {...
Could someone please help me write this in Python? If time
allows, it you could include comments for your logic that would be
of great help.
This problem involves writing a program to analyze historical win-loss data for a single season of Division I NCAA women's basketball teams and compute from this the win ratio for each team as well as the conference(s) with the highest average win ratio. Background Whether it's football, basketball, lacrosse, or any other number of...
Please Implement this code using Java Eclipse.
CIS 1068 Assignment 8 Warm Up with Objects Due: Wednesday, March 25 70 points (+ up to 15 extra credit) The purpose of this assignment is to give you practice implementing your own classes. It also provides extra practice with arrays. Task Implement a class Task, which is used to represent a job that should be done. It should contain the following private fields: .name text description of what job should be done...
General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...