Question: In Java, I am reading txt. file from command line. Each line has a name followed by a number. I want to create an array

In Java,

I am reading txt. file from command line. Each line has a name followed by a number. I want to create an array thats size is twice the number of names in the txt file. I want to hash the names(key) by adding the ascii value of each letter then diving by size of array and taking the remainder as the location in the array. After each insertion into the array I want to print the location, name and number.

example input txt. file

joe 23

mary 2

bob 12

import java.io.*;

public class Sys {

public static void main(String[] args)throws Exception{ String inpfile=args[0]; FileReader fr= new FileReader(inpfile); BufferedReader br = new BufferedReader(fr); String st, inputStrings=""; //read strings from file System.out.println("Reading strings from file...");

}

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!