iftikhar ali's Profile

About

 
Points: 6

Contact

 

iftikhar ali
May 6, 2015 · Public

iftikhar ali
November 25, 2014 · Public

the output file should look something like:

DISTANCE CBAE = CBAE12
DISTANCE DEABD = DEABD21
SHORTEST CA = CBA8
POSSIBLE CA = CBA8 CBDA11 CBADA12 CEA12 CBDADA15 CBEA15

iftikhar ali
November 25, 2014 · Public

in put file is a txt file and the contents are:

AB5 AD2 AE4 BC3 BD6 BE8 CE8 DE6
DISTANCE CBAE
DISTANCE DEABD
SHORTEST CA
POSSIBLE CA15

iftikhar ali
November 25, 2014 · Public

my code for the problem so far is as follows:

import java.io.*;

public class TestProg {
public static void main(String[] args)throws IOException
{
String SplitBy = " ";
BufferedReader br = null;
String sCurrentLine = "";
String[] st = new String[sCurrentLine.length()];
try
{
br = new BufferedReader(new FileReader("C:\\Users\\iftikhar\\workspace\\TestProgram\\input.txt"));
while ((sCurrentLine = br.readLine()) != null)
{
st[] = sCurrentLine.split(SplitBy);
System.out.println(st);

}
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if (br != null)br.close();
}
catch (IOException ex)
{
ex.printStackTrace();
}
}

iftikhar ali
November 25, 2014 · Public

I stuck in a string manipulating program in java and need help (f1) !!!
the description of the problem is as follows:
Problem Description

You will be provided with an input file which defines a graph and a series of questions relating to the graph. Your program will need to read this input file and output the answers to an output file.

Input

The program must accept a single argument, a path to the input file. e.g. "~/input.txt”
The input file will be structured as follows:

The first line will be the graph definition, a single line of routes separated by spaces.
A route will be defined as AC5 (i.e. The distance from A to C is 5).
Following the problem definition each line will represent one of the following questions (The routes included in these questions are examples only).
DISTANCE CBAE What is calculated distance of the route CBAE? The answer should be the route, including distance. i.e. CBAE12
SHORTEST CA What is the shortest route from C to A? The answer should be the route, including distance. i.e. CBA12
POSSIBLE CA15 What are the possible routes from C to A with a maximum distance of 15? The answer should be all routes, including distances, separated by spaces. i.e. CBA8 CBADA12 CBDA11 CBDADA15 CEA12 CBEA15
The input file can contain any number of questions, in any order.

Please find an example ‘input.txt' attached.

Output

Output the answers to a file named 'output.txt', one answer per line, in the following format:

DISTANCE CBAE = CBAE12