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   ...
Stack2540Array   import java .io .*; import java . util .*; public class Stack2540Array { int CAPACITY...
Stack2540Array   import java .io .*; import java . util .*; public class Stack2540Array { int CAPACITY = 128; int top ; String [] stack ; public Stack2540Array () { stack = new String [ CAPACITY ]; top = -1; } 1 public int size () { return top + 1; } public boolean isEmpty () { return (top == -1); } public String top () { if ( top == -1) return null ; return stack [ top ]; }...
I need a java flowchart diagram for the following code: import java.util.*; public class Main {...
I need a java flowchart diagram for the following code: import java.util.*; public class Main {    public static void main(String[] args) {    Scanner sc=new Scanner(System.in);           System.out.print("Enter the input size: ");        int n=sc.nextInt();        int arr[]=new int[n];        System.out.print("Enter the sequence: ");        for(int i=0;i<n;i++)        arr[i]=sc.nextInt();        if(isConsecutiveFour(arr))        {        System.out.print("yes the array contain consecutive number:");        for(int i=0;i<n;i++)        System.out.print(arr[i]+" ");   ...
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...
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...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT