Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use the provided URLDissector.java as a starting point to create FractionReader.java . Instead of reading URL's, read fractions from the file fractions.txt , one per

Use the provided URLDissector.java as a starting point to create FractionReader.java. Instead of reading URL's, read fractions from the file fractions.txt, one per line, add them to an ArrayList, and print them in reverse order with their values.

Expected Output

110/50 = 2.2 99/98 = 1.010204081632653 1/5 = 0.2 7/8 = 0.875 2/3 = 0.6666666666666666 5/6 = 0.8333333333333334 21/7 = 3.0 3/4 = 0.75 

Fraction.txt

3/4 21/7 5/6 2/3 7/8 1/5 99/98 110/50

//******************************************************************** // URLDissector.java Author: Lewis/Loftus // // Demonstrates the use of Scanner to read file input and parse it // using alternative delimiters. //********************************************************************

import java.util.Scanner; import java.io.*;

public class URLDissector { //----------------------------------------------------------------- // Reads urls from a file and prints their path components. //----------------------------------------------------------------- public static void main(String[] args) throws IOException { String url; Scanner fileScan, urlScan;

fileScan = new Scanner(new File("urls.inp"));

// Read and process each line of the file while (fileScan.hasNext()) { url = fileScan.nextLine(); System.out.println("URL: " + url);

urlScan = new Scanner(url); urlScan.useDelimiter("/");

// Print each part of the url while (urlScan.hasNext()) System.out.println(" " + urlScan.next());

System.out.println(); } } }

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

Contemporary Issues In Database Design And Information Systems Development

Authors: Keng Siau

1st Edition

1599042894, 978-1599042893

More Books

Students also viewed these Databases questions

Question

Were they made on a timely basis?

Answered: 1 week ago

Question

Did the decisions need to be made, or had they already been made?

Answered: 1 week ago

Question

When there was controversy, was it clear who had the final say?

Answered: 1 week ago