Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code the following assignment in java without using hashmap but arrays. Thank you! Your project is to read in a series of fractions from

Please code the following assignment in java without using hashmap but arrays. Thank you!
Your project is to read in a series of fractions from a text file, which will have each line formatted as follows: A/B. A sample text file is listed below, and the purpose of your program is to read in each fraction and count the number of occurrences for the current fraction. When all the input is consumed (or as the input is consumed), your program will print out its list of unique fraction and their corresponding count see the output below (and you may assume no blank lines or misleading characters; see the text file link on the website for one of the actual inputs Ill use when testing your submission).
Sample Input File named fractions.txt:
6/3
4/2
5/9
80/90
800/900
15/25
5/5
1/1
1/10
1/100
1/1000
1/3
2/6
1/2
1/3
1/1
1/4
1/5
1/6
1/7
1/8
1/9
2/1
2/2
2/3
2/4
2/5
2/6
2/7
2/8
2/9
Sample Console Output
6/3 has a count of 3
7/3 has a count of 1
NOTE: it is also fine (though not required) if your program simplifies the fractions so that the output is:
2/1 has a count of 3
7/3 has a count of 1
But either way, 6/3 and 12/6 count as the same fraction, so you do need some mechanism for determining if two fractions that look different are actually the same. The only optional part of the assignment is how you display them in the end.
Notes & Hints
Be sure to put code that gets lengthy into its own method!
This assignment is particularly guiding in the outcomes section; expect future assignments to test your ability to build your own programming contract for the problem at hand.
Test your code as you add features (either methods or variables) incrementally, making sure your small change works as you envisioned it to.
Try to keep in mind basic structured programming principles such as modular design (ie, decompose complex tasks into individual methods), good variable & methods names (self-documenting code), and comments.
Consider reading one line at a time (with scanner.nextLine()), and using the splitLinks to an external site. function (defined in class String) to give you an array with two elements in it (the numerator and denominator, respectively).

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions

Question

Describe different dimensions of suicide.

Answered: 1 week ago