Question: In this project, you will use radix.txt as the input file, and output the integers SORTED USING RADIX SORT. Your main program will input the

In this project, you will use radix.txt as the input file, and output the integers SORTED USING RADIX SORT.

Your main program will input the integers and put them into a QUEUE. It will then pass this queue to a method called radixSort which will sort the numbers in the queue, passing the sorted queue back to main.

The main program will then call another method to print the contents of this (sorted queue) .

Notes:

1. radixSort method will need an array of queues.

2. radixSort will NOT print the queue.

3. Use the java Queue class.

What I have so far:

import java.util.LinkedList; import java.util.Queue; import java.util.*; import java.io.*;

public class H8 { public static void main(String[] args) { File inFile=new File("radix.txt"); Scanner scnr=null; //Try/Catch try{ scnr=new Scanner(inFile); } catch(FileNotFoundException e){ } String temp = null; String[] fileStrings = new String[25]; createArray(fileStrings); Queue myQueue = new LinkedList<>(); for (int i=0; i< fileStrings.length;i++){ myQueue.add(fileStrings[i]); } System.out.println(getLength(fileStrings)); } public static void createArray (String[]nums){ File inFile=new File("radix.txt"); Scanner scnr=null; //Try/Catch try{ scnr=new Scanner(inFile); } catch(FileNotFoundException e){ } String temp = null; int count = 0; while (scnr.hasNext()){ temp = scnr.next(); nums[count] = temp; System.out.println(nums[count]); count++; } }

public static int getLength(String[]nums){ int i; int max = 0; int count = 0; int size = nums.length; String s = null; for (i=0; i max){ max = count; } } } return max; } }

I cant get the getLength method to work which I want to return the max digits in the string that I am getting from the file...please help

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!