Answered step by step
Verified Expert Solution
Link Copied!

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
image text in transcribed
image text in transcribed
1 Description of the program In this assignment, you will write a Java program to do the followings 1. Read a sequence of values from a file into an array list 2. Print out the original list values. 3, Convert the original list values into bar values within the range of]030], and save them in a new array list. To do so, you must find th e maximum value in the list first, say max. The remaining values should be computed based on the the formula: value * 30/max, where value is the original value. . Print out the bar values 5. Print out the bar charts with the bar values 6. Sort the bar values using Collections.sortO 7. Print out the sorted bar chart Three sample input files are given to you. A sample output corresponding to input1.txt is shown in Figure 1 2 Requirements of the program: 1. You should implement methods for this program. If you implement everyt hing within main), you will lose 30 points 2. You may use the template file I provide to you. If you write on your own, you should provide similar methods as in the template file 3. Your program should prompt user to enter input file name. While only three input files are given, your program should accept other input file 4. Your program output should be neat, icluding labeling and spaces (See Figure 1) 5. Your program should have good style (indentation, whitespace, comments, vertical alignmen, ..)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Explain the various methods of job evaluation

Answered: 1 week ago

Question

Differentiate Personnel Management and Human Resource Management

Answered: 1 week ago

Question

Describe the functions of Human resource management

Answered: 1 week ago

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

3. Identify and describe nine cultural value orientations.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago