Well I'm almost done with part A of task 2 and I've hit a wall. Here's what I have to do:
Everything on there is pretty much done I think except for part 4 and its subsequent writing to the agentreport.txt. To be honest, I have no idea how to do this map. I don't even know where to begin. I found some basic syntax but that's about it. I really don't understand how the program is going to take each instance of the agent ID and then somehow scan the amount? Here's the listings.txt and what the agentreport.txt should look like:
Example listings.txt file:
110001 commercial 500000.00 101
110223 residential 100000.00 101
110020 commercial 1000000.00 107
110333 land 30000.00 105
110442 farm 200000.00 106
110421 land 40000.00 107
112352 residential 250000.00 110
Example agentreport.txt file:
COMMERICAL
FARM
LAND
RESIDENTIAL
101 600000.00
105 30000.00
106 200000.00
107 1040000.00
110 250000.00
I honestly have no idea what the **** to do on this and I don't understand how the hell it "reads" the amount. Here's my code so far, maybe you can help me understand this:
package agentreport;
import java.util.Scanner;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.util.Set;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
/**
*
* @author DriXnaK
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
throws FileNotFoundException
{
Scanner console = new Scanner(System.in);
System.out.print("Input File: ");
String inputFileName = console.next();
//Creates treeset propertyType
Set propertyType = new TreeSet();
//Adds property types to set
propertyType.add("farm");
propertyType.add("land");
propertyType.add("residential");
propertyType.add("commercial");
//Creates FileReader object with name of input file.
FileReader reader = new FileReader("C:\\Users\\DriXnaK\\Documents\\NetBeansProjects\\A gentReport\\listings.txt");
//Creates scanner object from FileReader object.
Scanner agentReport = new Scanner(reader);
//Prints out to agentreport.txt.
System.out.print("Output file: ");
PrintWriter outAgentReport = new PrintWriter("C:\\Users\\DriXnaK\\Documents\\NetBeansProjects\\A gentReport\\agentreport.txt");
/*Creates set iterator and lists all elements in the propertyType set.
Converts them to uppercase before printing to the agentreport.txt*/
Iterator propertyIterator = propertyType.iterator();
while (propertyIterator.hasNext())
{
String upperCaseProperty = propertyIterator.next();
upperCaseProperty = upperCaseProperty.toUpperCase();
outAgentReport.println(upperCaseProperty);
}
outAgentReport.println(" ");
outAgentReport.close();
}
}
Everything on there is pretty much done I think except for part 4 and its subsequent writing to the agentreport.txt. To be honest, I have no idea how to do this map. I don't even know where to begin. I found some basic syntax but that's about it. I really don't understand how the program is going to take each instance of the agent ID and then somehow scan the amount? Here's the listings.txt and what the agentreport.txt should look like:
Example listings.txt file:
110001 commercial 500000.00 101
110223 residential 100000.00 101
110020 commercial 1000000.00 107
110333 land 30000.00 105
110442 farm 200000.00 106
110421 land 40000.00 107
112352 residential 250000.00 110
Example agentreport.txt file:
COMMERICAL
FARM
LAND
RESIDENTIAL
101 600000.00
105 30000.00
106 200000.00
107 1040000.00
110 250000.00
I honestly have no idea what the **** to do on this and I don't understand how the hell it "reads" the amount. Here's my code so far, maybe you can help me understand this:
package agentreport;
import java.util.Scanner;
import java.io.FileReader;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.TreeSet;
import java.util.Set;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
/**
*
* @author DriXnaK
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args)
throws FileNotFoundException
{
Scanner console = new Scanner(System.in);
System.out.print("Input File: ");
String inputFileName = console.next();
//Creates treeset propertyType
Set
//Adds property types to set
propertyType.add("farm");
propertyType.add("land");
propertyType.add("residential");
propertyType.add("commercial");
//Creates FileReader object with name of input file.
FileReader reader = new FileReader("C:\\Users\\DriXnaK\\Documents\\NetBeansProjects\\A gentReport\\listings.txt");
//Creates scanner object from FileReader object.
Scanner agentReport = new Scanner(reader);
//Prints out to agentreport.txt.
System.out.print("Output file: ");
PrintWriter outAgentReport = new PrintWriter("C:\\Users\\DriXnaK\\Documents\\NetBeansProjects\\A gentReport\\agentreport.txt");
/*Creates set iterator and lists all elements in the propertyType set.
Converts them to uppercase before printing to the agentreport.txt*/
Iterator
while (propertyIterator.hasNext())
{
String upperCaseProperty = propertyIterator.next();
upperCaseProperty = upperCaseProperty.toUpperCase();
outAgentReport.println(upperCaseProperty);
}
outAgentReport.println(" ");
outAgentReport.close();
}
}
Comment