Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.*; import java.io.File; import java.io.FileNotFoundException; public class SortedBarChart { /** * Read a sequence of positive integers from a given input file, * and
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;
public class SortedBarChart
{
/**
* Read a sequence of positive integers from a given input file,
* and construct an array list out of them.
*
* @param fileName: the input file name
* @return an array list of values
*/
public static ArrayList readValues(String fileName) throws FileNotFoundException
{
ArrayList list = new ArrayList();
//....
return list;
}
/**
* Return the largest element in the array list.
*
* @param list: the input list
* @return the largest element in list
*/
public static int findMax(ArrayList list)
{
int max=0;
//...
return max;
}
/**
* Prints a chart of asterisks with list value, based on the input list.
*
* @param list: the input list
*/
public static void printBarChart(ArrayList list)
{
//...
}
/**
* Prints the list value in one line
*
* @param list the input list
*/
public static void printArrayValues(ArrayList list)
{
//...
}
/**
* Convert the list valeus into corresponding bar values proportion to the largest element in the list.
* Truncate the fraction part if the resulting bar value is not a whole number
*
* @param list the input list
*/
public static ArrayList convertBarValues(ArrayList list)
{
ArrayList newList = new ArrayList();
//...
return newList;
}
public static void main(String[] args)
{
//...
}
}
input1.txt
20 30 40 50 25 90 65
input2.txt
200 300 400 500 250 900 650
input3.txt
2000 3000 4000 5000 2500 9000 6500
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started