
MotoGpRider.java
import java.util.*;
public class MotoGpRider{
String lastname;
String firstname;
int racingnumber;
String nation;
String motorcycle;
int w_champ_points;
int w_champ_position;
int[] finishes = new int[3];
public MotoGpRider(){
this.lastname = null;
this.firstname=null;
this.racingnumber = 0;
this.nation = null;
this.motorcycle = null;
this.w_champ_points = 0;
this.w_champ_position = 0;
}
public MotoGpRider(String lastname,String firstname,int racingnumber,String nation,String motorcycle,int w_champ_points,int w_champ_position,int[] finishes){
this.lastname = lastname;
this.firstname=firstname;
this.racingnumber = racingnumber;
this.nation = nation;
this.motorcycle = motorcycle;
this.w_champ_points = w_champ_points;
this.w_champ_position =w_champ_position;
this.finishes = finishes;
}
public String getLastname(){
return lastname;
}
public String getFirstname(){
return firstname;
}
public int getRacingnumber(){
return racingnumber;
}
public String getNation(){
return nation;
}
public String getMotorcycle(){
return motorcycle;
}
public int getW_champ_points(){
return w_champ_points;
}
public int getW_champ_position(){
return w_champ_position;
}
public int[] getFinishes(){
return finshes;
}
public String getName(){
return firstname+lastname;
}
public int total_num_of_finishes(){
int count=0;
for(int i=0; i<finishes.length; i++){
count = count + finishes[i];
}
return count;
}
}
RiderList.java
import java.util.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
pulic class RiderList{
public ArrayList<MotoGpRider> addRider(String inputfile){
int count=0;
String lastname;
String firstname;
int racingnumber;
String nation;
String motorcycle;
int w_champ_points;
int w_champ_position;
int[] finishes = new int[3];
ArrayList<MotoGpRider> riderss = new
ArrayList<MotoGpRider>();
MotoGpRider rider ;
try (BufferedReader br = new BufferedReader(new FileReader(FILENAME))) {
String str;
String[] arr = new String[10];
while ((str = br.readLine()) != null) {
if(count<=10){
arr = str.split(" ");
lastname = arr[0];
firstname = arr[1];
racingnumber = Integer.parseInt(arr[2]);
nation = arr[3];
motorcycle = arr[4];
w_champ_points = Integer.parseInt(arr[5]);
w_champ_position = Integer.parseInt(arr[6]);
finishes[0] = Integer.parseInt(arr[7]);
finishes[1] = Integer.parseInt(arr[8]);
finishes[2] = Integer.parseInt(arr[9]);
rider = new
MotoGpRider(lastname,firstname,racingnumber,nation,motorcycle,w_champ_points,w_champ_position,finishes);
riderss.add(rider);
}
else
break;
}
return riderss;
} catch (IOException e) {
e.printStackTrace();
}
}
public void printRider(String
outputfilepath,ArrayList<MotoGpRider> riderss){
File fout = new File(outputfilepath);
FileOutputStream fos = new
FileOutputStream(fout);
BufferedWriter bw = new BufferedWriter(new
OutputStreamWriter(fos));
bw.write("2018 World Championship
Statistics");
bw.newLine();
bw.write("RIDER NAME \t \t NUMBER \t \t POINTS \t \t POSITION
");
bw.newLine();
bw.write("----------------------------------------------------------------------------------------------------");
bw.newLine();
for(int i=0; i<riderss.size(); i++){
bw.write(riderss[i].getName() + "\t \t" +
riderss[i].getRacingnumber() + "\t \t" +
riderss[i].getW_champ_points() + "\t \t" +
riderss[i].getW_champ_position() );
bw.newLine();
}
bw.newLine();
bw.write("RIDERS");
bw.newLine();
for(int i=0; i<riderss.size();i++){
bw.write("---------------------------------");
bw.newLine();
bw.write(riderss[i].getName());
bw.newLine();
bw.write("---------------------------------");
bw.newLine();
bw.write("Number \t :" + riderss[i].getRacingnumber());
bw.newLine();
bw.write("MotorCycle \t :" + riderss[i].getMotorcycle());
bw.newLine();
bw.write("Nation \t :" + riderss[i].getNation());
bw.newLine();
bw.write("TOP 3 Finishes \t :" +
riderss[i].total_num_of_finishes());
bw.newLine();
bw.newLine();
}
bw.close();
}
public static void main(String[] args){
int numberof_riders = 0;
ArrayList<MotoGpRider> riders = new
ArrayList<MotoGpRider>();
String inputfile = ""; // Write your input text file path here.
riders = addRider(inputfile); // Reading data from text file and storing them into array.
String outputfilepath = ""; // Write your output text file path here.
printRider(outputfilepath,riders); // Printing the required data into output file whose path is mentioned in above line.
}
}
If you left with any doubt. Feel free to ask.
Any little bit of information will be helpful. Thank you. Problem Statement You are to develop a program to read Mo...
// READ BEFORE YOU START:
// You are given a partially completed program that creates a list of students for a school.
// Each student has the corresponding information: name, gender, class, standard, and roll_number.
// To begin, you should trace through the given code and understand how it works.
// Please read the instructions above each required function and follow the directions carefully.
// If you modify any of the given code, the return types, or the parameters, you...
Problem statement For this program, you are to implement a simple machine-learning algorithm that uses a rule-based classifier to predict whether or not a particular patient has diabetes. In order to do so, you will need to first train your program, using a provided data set, to recognize a disease. Once a program is capable of doing it, you will run it on new data sets and predict the existence or absence of a disease. While solving this problem, you...
Write in JAVA Get Familiar with the Problem Carefully read the program description and look at the data file to gain an understanding of what is to be done. Make sure you are clear on what is to be calculated and how. That is, study the file and program description and ponder! Think! The Storm Class Type Now concentrate on the Storm class that we define to hold the summary information for one storm. First, look at the definition of...
WRITE JAVA PROGRAM Problem Statement You are required to write a stock price simulator, which simulates a price change of a stock. When the program runs, it should do the following: Create a Stock class which must include fields: name, symbol, currentPrice, nextPrice, priceChange, and priceChangePercentage. The Stock class must have two constructor: a no-argument constructor and a constructor with four parameters that correspond to the four fields. o For the no-argument constructor, set the default value for...
Topics: list, file input/output (Python) You will write a program that allows the user to read grade data from a text file, view computed statistical values based on the data, and to save the computed statistics to a text file. You will use a list to store the data read in, and for computing the statistics. You must use functions. The data: The user has the option to load a data file. The data consists of integer values representing student...
ANY HELP PLEASE. PLEASE READ THE WHOLE INSTRUCTION THANK YOU Write a program GS.java that will be responsible for reading in the names and grades for a group of students, then reporting some statistics about those grades. The statistics to be gathered are the number of scores entered, the highest score and the name(s) of the student(s) who earned that score, the lowest score and the name(s) of the student(s) who earned that score, and the average score for the...
Problem: You will write a program to compute some statistics based on monthly average temperatures for a given month in each of the years 1901 to 2016. The data for the average August temperatures in the US has been downloaded from the Climate Change Knowledge Portal, and placed in a file named “tempAugData.txt”, available on the class website. The file contains a sequence of 116 values. The temperatures are in order, so that the first one is for 1901, the...
Problem: You will write a program a C++ to compute some statistics based on monthly average temperatures for a given month in each of the years 1901 to 2016. The data for the average August temperatures in the US has been downloaded from the Climate Change Knowledge Portal, and placed in a file named “tempAugData.txt”, available on the class website. The file contains a sequence of 116 values. The temperatures are in order, so that the first one is for...
Use C++
For this week’s lab you will write a program to read a data file
containing numerical values, one per line. The program should
compute average of the numbers and also find the smallest and the
largest value in the file. You may assume that the data file will
have EXACTLY 100 integer values in it. Process all the values out
of the data file. Show the average, smallest, largest, and the name
of the data file in the...
C++ ONLY This is your first ever program using object oriented methodology. In this assignment you will need to instantiate (create) object(s) and invoke their member functions to perform different tasks. The program is to keep track of customer orders and to create reports as needed. At minimum you will need several objects to be instantiated throughout the program such as: An OrderProcessor object Order objects (stored in an array) Let’s get to class design now. Class Design class Order:...