Question

In: Computer Science

Hi I have problem with run this JAVA file import java.io.*; public class DataPresenter { public...

Hi

I have problem with run this JAVA file

import java.io.*;
public class DataPresenter {
public static void main (String args []) {
System.out.println("File:../SmallAreaIncomePovertyEstData.text");
System.out.println("Id" + "\t" + "Population" + "\t" + "ChildPop"
+ "\t" + "CPovPop" + "\t" + "CPovPop%");
}// read the data

try (FileReader fr = new FileReader("File: C:\\605.201/SmallAreaIncomePovertyEstData.text"))
{
int c;
while (( c = fr.read())!= -1){
System.out.print((char) c);
}
}
catch(IOException e) {
System.out.println("I/O Error" + e);
}   
}

Please help to fix

Solutions

Expert Solution

Please let me know if anything is required.

Copyable code :

import java.io.*;

public class DataPresenter {
public static void main (String args []) {
  
System.out.println("File:../SmallAreaIncomePovertyEstData.text");
System.out.println("Id" + "\t" + "Population" + "\t" + "ChildPop"
+ "\t" + "CPovPop" + "\t" + "CPovPop%");

try //try block for opening the file
{
//creating file reader object
//replace your full path of file here
FileReader fr = new FileReader("SmallAreaIncomePovertyEstData.txt");//("File: C:\\605.201/SmallAreaIncomePovertyEstData.text");
int c;
while (( c = fr.read())!= -1){ //reading the contents of the file
System.out.print((char) c); //printing the contents of the file to the console
}
}
catch(IOException e) { // catch block for the file opening, if file nit exist then it will throw the error
System.out.println("I/O Error" + e);
}   
  
}


}

Sample input:

Sample output 1:

Sample output2:

Duwuy T op Main.java SmallArealncome... : 1 1 20 10 2 3 2 2 34 5 7 3 3 3 43 5 6 7 4 4 5 6 7 8 U + WNA 5 |

File: ../SmallAreaIncome PovertyEstData.text Id Population ChildPop CPOVPop CPovPop: 1/0 Errorjava.io.FileNotFoundException: input (No such file or directory)

Id File: ../ SmallAreaIncome PovertyEstData.text Population ChildPop CPovPop CPOVPop/ 1 20 10 2 3 2 34 5 7 3 3 43 5 6 7 4 5 6 7 8


Related Solutions

Convert this java code from hashmap into arraylist. import java.io.*; import java.util.*; public class Solution {...
Convert this java code from hashmap into arraylist. import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); HashMap labs = new HashMap(); while (true) { System.out.println("Choose operation : "); System.out.println("1. Create a Lab"); System.out.println("2. Modify a Lab"); System.out.println("3. Delete a Lab"); System.out.println("4. Assign a pc to a Lab"); System.out.println("5. Remove a pc from a Lab"); System.out.println("6. Quit"); int choice = sc.nextInt(); String name=sc.nextLine(); switch (choice) { case 1:...
Please convert this java program to a program with methods please. import java.io.*; import java.util.*; public...
Please convert this java program to a program with methods please. import java.io.*; import java.util.*; public class Number{ public static void main(String[] args) {    Scanner scan = new Scanner(System.in); System.out.println("Enter 20 integers ranging from -999 to 999 : "); //print statement int[] array = new int[20]; //array of size 20 for(int i=0;i<20;i++){ array[i] = scan.nextInt(); //user input if(array[i]<-999 || array[i]>999){ //check if value is inside the range System.out.println("Please enter a number between -999 to 999"); i--; } } //...
I'm getting an error for this code? it won't compile import java.util.*; import java.io.*; public class...
I'm getting an error for this code? it won't compile import java.util.*; import java.io.*; public class Qup3 implements xxxxxlist {// implements interface    // xxxxxlnk class variables    // head is a pointer to beginning of rlinked list    private node head;    // no. of elements in the list    // private int count; // xxxxxlnk class constructor    Qup3() {        head = null;        count = 0;    } // end Dersop3 class constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor    data = d;    next = null; } } class ACOLinkedList {// a Singly Linked List    Node head; // head of list    public void insert(int data){ // Method to insert a new node        Node new_node = new Node(data); // Create a new node with given data        new_node.next = null;        if (head == null) // If the...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor    data = d;    next = null; } } class ACOLinkedList {// a Singly Linked List    Node head; // head of list    public void insert(int data){ // Method to insert a new node        Node new_node = new Node(data); // Create a new node with given data        new_node.next = null;        if (head == null) // If the...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor   ...
import java.io.*; import java.util.Scanner; class Node { int data; Node next; Node(int d){ // Constructor    data = d;    next = null; } } class ACOLinkedList {// a Singly Linked List    Node head; // head of list    public void insert(int data){ // Method to insert a new node        Node new_node = new Node(data); // Create a new node with given data        new_node.next = null;        if (head == null) // If the...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class...
Can someone please convert this java code to C code? import java.util.LinkedList; import java.util.List; public class Phase1 { /* Translates the MAL instruction to 1-3 TAL instructions * and returns the TAL instructions in a list * * mals: input program as a list of Instruction objects * * returns a list of TAL instructions (should be same size or longer than input list) */ public static List<Instruction> temp = new LinkedList<>(); public static List<Instruction> mal_to_tal(List<Instruction> mals) { for (int...
Using the following in Java- package intersectionprinter; import java.awt.Rectangle; public class IntersectionPrinter { public static void...
Using the following in Java- package intersectionprinter; import java.awt.Rectangle; public class IntersectionPrinter { public static void main(String[] args) { Rectangle r1 = new Rectangle(0,0,100,150); System.out.println(r1);    Rectangle r2 = new Rectangle(50,75,100,150); System.out.println(r2);    Rectangle r3 = r1.intersection(r2);    } } Write a program that takes both Rectangle objects, and uses the intersection method to determine if they overlap. If they do overlap, then print it's coordinates along with its width and height. If there is no intersection, then have the...
I can't figure out why this won't run. //CryptographyTest.java //package cryptography; import java.util.Scanner; public class CryptographyTest...
I can't figure out why this won't run. //CryptographyTest.java //package cryptography; import java.util.Scanner; public class CryptographyTest {    public static void main(String[] args) { // create a scanner object to read from user Scanner s = new Scanner(System.in); // prompt user for input option while(true) { // loop till user say exit System.out.println("Select Option:"); System.out.println("1. Encrypt"); System.out.println("2. Decrypt"); System.out.println("3. Exit"); String input = s.nextLine(); // get user input int option = 0; try { // check for valid input option...
what i have: import java.util.Scanner; public class examples1 { public static void main(String[] args) { Square...
what i have: import java.util.Scanner; public class examples1 { public static void main(String[] args) { Square shade = new Square(getside()); System.out.println("Your chooses are:"); System.out.println("\nCircle"); System.out.println("Triangle"); System.out.println("Rectangle"); System.out.println("Square"); boolean moreShapes = true; boolean userChoice = true; while(moreShapes) { Scanner shapes = new Scanner (System.in); System.out.println("\nWhat shape do you want:"); String yourShape = shapes.nextLine(); if (userChoice = shade != null) { shade.getSide(); } System.out.println("\nWhat are two size paramters of the shape you choose:"); String yourParameter = shapes.nextLine(); System.out.println("\nYour shape is: " +...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT