Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Work exercise 12.32, page 493, to design and implement a program to process data

ID: 3887281 • Letter: W

Question

Work exercise 12.32, page 493, to design and implement a program to process data from a given text file (used in the previous exercise). See problem statement for details and output format. Make your program modular using separate methods to perform specific tasks, such as reading the names from the files and writing the output table. Use exception handlings as needed.

*12.32 (Ranking summary) Write a program that uses the files described in Programming Exercise 12.31 and displays a ranking summary table for the first five girl’s and boy’s names as follows:
Year Rank 1 Rank 2 Rank 3 Rank 4 Rank 5 Rank 1 Rank 2 Rank 3 Rank 4 Rank 5 2010 Isabella Sophia Emma Olivia Ava Jacob Ethan Michael Jayden William 2009 Isabella Emma Olivia Sophia Ava Jacob Ethan Michael Alexander William ... 2001 Emily Madison Hannah Ashley Alexis Jacob Michael Matthew Joshua Christopher

Explanation / Answer

Hi ,

Please see below the class:

RankReader.java

import java.io.BufferedReader;

import java.io.FileReader;

import java.io.IOException;

public class RankReader {

/**

* @param args

*/

public static void main(String[] args) {

//Reading the content of a file named "RankList.txt"

BufferedReader br = null;

FileReader fr = null;

int lineCount =0;

String fileContent = "";

try {

fr = new FileReader("RankList.txt");

br = new BufferedReader(fr);

String sCurrentLine;

while ((sCurrentLine = br.readLine()) != null) {

if(lineCount !=0){

String [] lineArr = sCurrentLine.split(" ");

//Printing Year

System.out.println("Ramk list for "+lineArr[0]);

//Prining Girl's Rank list

System.out.println("Girl's Ranklist");

for(int i=1;i<=5;i++){

System.out.println("Rank "+i+" : "+lineArr[i]);

}

//Printing Boys's Rank list

System.out.println("Boy's Ranklist");

for(int i=6,j=1;i<=10;i++,j++){

System.out.println("Rank "+j+" : "+lineArr[i]);

}

}

lineCount++;

}

} catch (IOException e) {

System.out.println("Invalid File!");

}

}

}

RankList.txt

Ramk list for 2010
Girl's Ranklist
Rank 1 : Isabella
Rank 2 : Sophia
Rank 3 : Emma
Rank 4 : Olivia
Rank 5 : Ava
Boy's Ranklist
Rank 1 : Jacob
Rank 2 : Ethan
Rank 3 : Michael
Rank 4 : Jayden
Rank 5 : William
Ramk list for 2009
Girl's Ranklist
Rank 1 : Isabella
Rank 2 : Emma
Rank 3 : Olivia
Rank 4 : Sophia
Rank 5 : Ava
Boy's Ranklist
Rank 1 : Jacob
Rank 2 : Ethan
Rank 3 : Michael
Rank 4 : Alexander
Rank 5 : William
Ramk list for 2001
Girl's Ranklist
Rank 1 : Emily
Rank 2 : Madison
Rank 3 : Hannah
Rank 4 : Ashley
Rank 5 : Alexis
Boy's Ranklist
Rank 1 : Jacob
Rank 2 : Michael
Rank 3 : Matthew
Rank 4 : Joshua
Rank 5 : Christopher

Sample output:

Ramk list for 2010
Girl's Ranklist
Rank 1 : Isabella
Rank 2 : Sophia
Rank 3 : Emma
Rank 4 : Olivia
Rank 5 : Ava
Boy's Ranklist
Rank 1 : Jacob
Rank 2 : Ethan
Rank 3 : Michael
Rank 4 : Jayden
Rank 5 : William
Ramk list for 2009
Girl's Ranklist
Rank 1 : Isabella
Rank 2 : Emma
Rank 3 : Olivia
Rank 4 : Sophia
Rank 5 : Ava
Boy's Ranklist
Rank 1 : Jacob
Rank 2 : Ethan
Rank 3 : Michael
Rank 4 : Alexander
Rank 5 : William
Ramk list for 2001
Girl's Ranklist
Rank 1 : Emily
Rank 2 : Madison
Rank 3 : Hannah
Rank 4 : Ashley
Rank 5 : Alexis
Boy's Ranklist
Rank 1 : Jacob
Rank 2 : Michael
Rank 3 : Matthew
Rank 4 : Joshua
Rank 5 : Christopher

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote