Question: pseudocode of this code in java : package Project1; import java.io.File;//for handling external file(s) import java.io.IOException;//for handling exceptions import java.util.Scanner;//for user inputs public class Projec1_final2

pseudocode of this code in java : package Project1; import java.io.File;//for handling external file(s) import java.io.IOException;//for handling exceptions import java.util.Scanner;//for user inputs public class Projec1_final2 { public static void main(String[] args) { int year;// the year for finding the names ranking position char gender; String name; Scanner SC = new Scanner(System.in); System.out.println("Enter a year between 2001 and 2010"); year = SC.nextInt(); System.out.println("Enter the Gender(M/F)"); gender = SC.next().charAt(0); System.out.println("Enter the Name whose rank has to be found"); name = SC.next(); String[][] nameFile = fileAppending(gender); nameRanking(year, name, nameFile); } public static String[][] fileAppending(char gender) { String[][] girlName = new String[10][1000], boyName = new String[10][1000]; for (int fileIndex = 0; fileIndex < 10; fileIndex++) { File file = new File("src\\pr\\babynameranking" + (2001 + fileIndex) + ".txt"); try (Scanner fileScanner = new Scanner(file)) { for (int fileRow = 0; fileScanner.hasNextLine(); fileRow++) { String[] line = fileScanner.nextLine().split("\\s+"); if (gender == 'M') boyName[fileIndex][fileRow] = line[1]; else girlName[fileIndex][fileRow] = line[3]; } } catch (IOException ioException) { ioException.printStackTrace(); break; } } if (gender == 'M') return boyName; else return girlName; } public static void nameRanking(int year, String name, String[][] nameFile) { int yearIndex = (year % 100) - 1; for (int fileRow = 0; fileRow < 1000; fileRow++) { if (nameFile[yearIndex][fileRow].equalsIgnoreCase(name)) { System.out.println( nameFile[yearIndex][fileRow] + " has the name rank " + (fileRow + 1) + " in year " + year); break; } else if (fileRow == 999) System.out.println(name + " doesn't belong to the ranklist in year " + year); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!