Program Should Read File Contents And Store Information In Array Of Golfers

Dec 3, 2014

The main method will drive your program by doing the following:

-Create an array to hold all the individual golfers and par scores (type is Golfer[ ]).
-Prompt the user for a data file containing the Par scores and the player names and score. The format of the input file should look like

Par, 3, 4, 4, 3, 4, 3, 5, 3, 4
George, 3, 3, 4, 3, 4, 2, 3, 3, 4
Paul, 4, 5, 4, 3, 6, 3, 4, 3, 5
Ringo, 3, 3, 4, 3, 4, 2, 4, 3, 4
John, 4, 4, 4, 3, 4, 2, 5, 3, 4

Your program should read the file contents and store the information in your array of Golfers.

View Replies


ADVERTISEMENT

Read Characters From Txt File / Store Them Into 2D Array And Print Information

Oct 10, 2014

The point of this program is to read characters from a txt file and store them into a 2D array. After this has been accomplished, the information is to be printed in the same manner it is read from in the txt file.

Here is the code I have so far:

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) throws FileNotFoundException

[Code] ....

And this is the error I am receiving when trying to accomplish the goal of the project:

Exception in thread "main" java.lang.NumberFormatException: For input string: "############"
at java.lang.NumberFormatException.forInputString(Unk nown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at Maze.<init>(Maze.java:15)
at Main.main(Main.java:20)

What's going on here and how I can correct this?? The information I am trying to store in a 2D array and then print is this:

############
#.#........#
#.#.######.#
#.#....#...#
#.###.*#.#.#
#...####.#.#
#.#.#..#.#.#
#.#.#.##.#.#
#o#......#.#

View Replies View Related

Read CSV File And Store Contents On Column Basis

Sep 25, 2014

I want to read this csv file and store contents on column basis; as date (single array) for all dates. open, high, low and close and be able to manipulate individual elements of the array such as Sum += close[i];

public void pratice() throws Exception {
// Create a File instance
BufferedReader br=new BufferedReader(new FileReader("gtk.csv"));
content = new String[1000];
while(content !=null) {
content[++count] = br.readLine();

[Code] .....

the file looks like this

date Open high low close

12-12-2011 15.00 15.40 14.5 15.2

11-12-2011 15.02 15.70 14.9 15.00

10-12-2011 14.70 16.00 14.70 15.02

...

View Replies View Related

Read ASCII Art Map And Store Information In 2D Array

Feb 12, 2014

I've written some code to do this, but it's not working as I expect. This is what the ASCII map looks like:

###################
#.................#
#......G........E.#
#.................#
#..E..............#
#..........G......#
#.................#
#.................#
###################

Here's how I've tried to store the information in a 2D array:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
 public class Map {
 public void importMap() throws IOException{
BufferedReader br = new BufferedReader(new FileReader("map.txt"));
String line;

[Code] ....

But it's not printing out what I'm expecting. It's printing out:

[[#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [#, #, #, #, #, #, #, #, #], [

What is printed is much larger than what I've copy and pasted but I can't post it all here.

The error I get is:

Exception in thread "main" java.io.IOException: Stream closed
at java.io.BufferedReader.ensureOpen(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at java.io.BufferedReader.readLine(Unknown Source)
at Map.importMap(Map.java:26)
at Map.main(Map.java:44)

View Replies View Related

Open A File And Store Contents Into A Two Dimensional Array

Feb 11, 2014

So I am trying to open a file and store the contents into a two dimensional array. I seem to have no problem using this same basic code to read the file and output it. But when I try to change it so that all the data is stored into the array, it does not work.

Java Code:

public void convertFile()
{
String filePath = ("C:UsersBradDownloadsFB1.csv");
String [][] rowCol = new String [429][6];
try
{
BufferedReader br = new BufferedReader(new FileReader(filePath));
StringTokenizer st = null;
System.out.println("Your file is being converted to an array. This may take several minutes.");

[code]....

View Replies View Related

JSP :: How To Read Contents Of Resume And Store In Database

Jul 23, 2014

Am doing a JSP project for maintaining the details of the interview candidates so now I want to know "How to read the contents of the resume and store in the database"

View Replies View Related

Hurricane Java Project - Read Information From Data File And Run It Through But Program

Dec 2, 2014

I am now stuck. I am writing a program that reads information from a data file and runs it through but program. However, I am almost finished with the program, but cannot figure out the last few parts.

public class Storm {
private final double KnotsToMPH = 1.15;
// global user-defined types:
private int beginDate;
private int duration;
private String name;

[Code] .....

I have not attached the data file because it contains a total of 360 lines of hurricane information.

View Replies View Related

Program That Is To Store DVD Information?

Nov 11, 2014

i have a program that is to store DVD information and when i enter all the information asked it returns no info. I have a DVD inventory file and a DVD extended file.

DVDinventoryprogram class
package inventory2;
import java.util.Scanner;

[Code]....

View Replies View Related

Write A Java Program To Store Employee Information In A Linked List

May 12, 2015

Write a java program to store employee information in a linked list, the program should implement the following functions:

The program should display the list of functions, and ask the user to enter the number of function that he/she wants to do, then perform the function as it is required in the previous table.

import java.util.*;
public class Employee {
Scanner in = new Scanner(System.in);
String Name;
String Address;
String Department;
int ID;
int Salary;

[code]....

this is my out put

Please choose a number:
1-Add a new employee
2-Update employee's info
3-Remove employee's info
4-Exit
1
Enter name:
Enter address:
2
Enter department:
3
Enter ID:
4
Enter salary:

now:

1- why are not my adding coming out in the output only the Enter name & Enter address ??

2- how can I add names and ID's and information to test that program

View Replies View Related

Read XML File And Delete Its Contents - Boolean Doesn't Appear To Work

Oct 17, 2014

I'm trying to read a xml file and delete it's contents. I do this by reading the file,writing it to a temp and then overwriting the original with the temp by renaming it

//overwrite original xml file with new file
boolean successful = outputFile.renameTo(inputFile);
System.out.println("success");

It does say the value of the local variable is not used however. I've debugged to ensure it hits the code it always prints out the line after too.It just does not overwrite my original xml file with the temp one.

It's had votes on stack so I thought that would of been reputableStack - overwrite but the second one got voted as a good answer. But still I would like to know if my code can work or not.

View Replies View Related

Read Information From File - How To Get Highest Value

Nov 12, 2014

The requirement asked me to write a Java program to read information from the file, display the original information along with the player's average score of the season (one line for each player), and announce who is the highest average-scoring player of the team. But I always only get the highest which show the last player.

Such like the output showed:

Smith 13.0 19.0 8.0 12.0 Player's average: 13.00
Badgley 5.0 Player's average: 5.00
Burch 15.0 18.0 16.0 Player's average: 16.33
Watson Player's average: 16.33
Knox 10.0 12.0 8.0 6.0 Player's average: 9.00
Casler 15.0 7.0 Player's average: 11.00
Winorburg 13.0 14.0 14.0 23.0 20.0 Player's average: 16.80
Morton 4.0 11.0 13.0 Player's average: 9.33
Seeling 16.0 8.0 9.0 11.0 Player's average: 11.00
Tanshi 5.0 13.0 10.0 Player's average: 9.33

The highest average-scoring player is: Tanshi

import java.util.Scanner;
import java.io.*;
public class PA7{
public static void main(String[] args) throws IOException{
String name = null;

[Code] .......

View Replies View Related

Best Way To Store Information?

Jul 7, 2014

I'm doing desktop application about recipes. User can create new recipe, add information. I want to sort recipes, save them somewhere, maybe make it possible to send recipes over network to other users. But I don't know where and how store information about those recipes. I always used to use .txt files for storing needed information, but it seems that it is not the best option.

View Replies View Related

Program That Use Array To Store 10 Numbers

Oct 16, 2014

i'm trying to write a program that uses an array to store 10 numbers. The numbers should be randomly generated ( Math.random() ), and they should be between 1 and 100 ( 1 and 100 inclusive ). The program should produce an output like the one below:

Element 1 = 23 ( Odd )
Element 2 = 15 ( Odd )
Element 3 = 32 ( Even )
Element 4 - 10 ( Even )
Element 5 - 99 ( Odd )
Element 6 - 1 ( Odd )

[Code]...

I have written code for this but its only showing me 0's after first number can you check whats wrong with my code. my code is.

class even/odd{
public static void main(String[]args){
int y=0;
int z=0;
int[] array= new int[11];
for(int x=1; x <array.length ; x++){
array[x]= (int) (Math.random()* 100);
 
[Code]...

View Replies View Related

Inventory Program - Displaying Information (Input From Array)

Sep 13, 2014

I'm working a an assignment for my IT/215 class and I'm having a little trouble with my arrays. My code compiles just fine but when it comes to displaying the information I've input into my array it doesn't seem to want to and I'm not sure what I'm doing wrong here. On line 136 originally I had [DVDs [count] = count+1]] but it wouldn't compile. I then put line 136 to [ DVDs[count] = new Inventory();] and I think that's were my issue is but I'm not sure....

// Purpose:the purpose of this software is to display inputs as wells as the stocks and price of inputs.

class Inventory
{
private double ItemNumber; //to store Item number
private String ItemName; //to store Item name
private double UnitsInStock; //to store number of units in stock
private double UnitPrice; //to store Unit price
private double InventoryValue; //to store Inventory value
private double TotalInventory; //to store Total Inventory value

[Code] .....

View Replies View Related

How To Store A File In Hashmap Or 2D Array

Sep 25, 2014

I have a file called statecapitals.txt that is read in, I want to store it in either a 2d array or hashmap and select a random state then Ask the user for the name of the capital. Then I want to Let them know if they are correct or not and have a choice to play as many times as they like. When they no longer want to play,I want to let them know how many they got correct and how many incorrect. I am not sure which would be better a hash map or 2d array and dont know where to start with each.

here is what the text file looks like:

Alabama - Montgomery
Alaska - Juneau
Arizona - Phoenix
Arkansas - Little Rock
California - Sacramento
Colorado - Denver

[code]....

View Replies View Related

Program To Store Total Rainfall For Each Of 12 Months Into Array Of Doubles

Oct 26, 2014

"Create a project called RainFall and a class nameD RainFall. Write a program that stores the total rainfall for each of 12 months into an array of doubles. The program should display total rainfall for the year, the average monthly rainfall, the month with the most rain and the month with the least rain. When outputting the month with the most and least rain, output the name of the month. This is what I have so far.

Scanner keyboard = new Scanner(System.in);
double averageMonthly;
double mostRain;
double leastRain;
int months;
double monthlyRain = 0;
double totalRain = 0;

[Code] ....

View Replies View Related

Store Data From A File Into Array Of Type Product?

Mar 17, 2015

public class InputFileData {
/**
* @param inputFile a file giving the data for an electronic
* equipment supplier’s product range
* @return an array of product details
* @throws IOException
*/
public static Product [] readProductDataFile(File inputFile)
throws IOException{
// YOUR CODE HERE
}

This code is meant to be used to read a text file and store the data in an array of type Product[]. I know how to read in a text file and have it sort it into an array, but I've never seen code laid out in this fashion before (specifically "public static Product[]", and I'm unsure how to work with "(File inputfile)". I've looked all over the place but can't find any examples of anything like this.

Also, the code given cannot be changed, as it's that code I have to work with.

I still don't understand how to use it as a whole. For example, do I read the file in the main and have this method read that in and output to the Product class? Do I read the file in this method? I can't work out how to make this work when I have to use this method.

View Replies View Related

Get Data From Config File And Store In Array Without Using Split Method

May 8, 2014

How i can get the data from a file, for a key that have multiple values without using split method and i want to store that data in an array

file name:"new.txt"[contains below data]
Name=google.com, yahoo.com,facebook.com
Attachment=abc1,abc2,abc3

I am successfully able to do this using following code

Properties props = new Properties();
String configFilePath = (Cjava_confignew.txt);
props.load(new FileReader(configFilePath));
String TestName = props.getProperty(Name);
String test[] = TestName.split(,);

Now i just want to store the values for key "Name" in array without using TestName.split(,); but i am not able to do this.

I have also used .yml file to avoid this but did not succeed, some way to do this

file name test.yml

Name
-google.com
-yahoo.com
-facebook.com

Attachment
-abc1
-abc2
-abc3

i want to store multiple values for single key(Name) within the array

View Replies View Related

Read Text File Into Object Array And Creating Random Access File

Dec 8, 2014

I am working on a project that requires me to build a database with random access file, representing products, the base product contains a name (about 30 characters), a price (double), and a quantity (integer). I have worked on this project for probably 15+ hours and have tried so many things and feel like I've barley made any progress...

The part i am really struggling with is taking the data from the text file and creating an object array with it using the product class. Once ive accomplished that, i have to use that data to create a random access file with the data.

Here is the base Product class that must be used to create the objects for the array.

public class Product
{
public String pName;
public String stringName;
public double price;
public int quanity;

[Code] .....

And then here is the data from the text file that i must extract to use to create product objects.

Dill Seed,938,34
Mustard Seed,100,64
Coriander Powder,924,18
Turmeric,836,80
Cinnamon (Ground Korintje),951,10
Cinnamon (Ground) Xtra Hi Oil (2x),614,31
Cinnamon (Ground) High Oil (1X),682,19

These continue for about 40-50 entries, they are not separated by a blank line though i had to add those so it would display correctly, each entry is on its own line with name separated with spaces, then price after a comma, then quantity after the second comma.....

View Replies View Related

Read Text File Into Array Ask User To Save File And Print Data

Jul 14, 2014

New to programming. Am supposed to create a program that reads a text file (of integers) and computes a series of computations on these integers. I don't have the code for the integers in my code yet, (i know how to do those), but am struggling getting the array to simply print in the print writer. I have the user select a text file, read the file with a scanner, and then save the computations done from my code into another file. specifically, the problem is as follows: Write a program that uses a file chooser dialog to select a file containing some integers. The file contains an integer N followed by N integers. The program then uses a file chooser dialog to let the user specify the name and location of an output file to write results to.The data written to the output file will be as follows

(1) The original list of N numbers from the input file,
(2) The original list of N numbers printed in reverse order of how they appear
in the input file.
(3) The sum and average of these numbers,
(4) The minimum of all the numbers,
(5) The maximum of all the numbers.

[import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;

[Code]....

View Replies View Related

Read File And Input Each Line Of File Into Array

Mar 21, 2015

I am trying to read a file and input each line of the file into an array. I have not set the array size as I was hoping to fill the array using a while loop. Unfortunately the scope of the array does to work inside the while loop so I am being told that the array 'students' has not been initialised even though it has just outside of the while loop. Is it possible to do what I am trying to without having the array initialised in the while loop as surely the array will be reset every time if it was in the while loop? Here is my code:

public static void students(String file) throws FileNotFoundException {
try {
File studentInfo = new File(file);
Scanner input = new Scanner(studentInfo);
String[] students;

[Code] ....

View Replies View Related

GUI Program - Read And Write To File

Oct 17, 2014

I'm rather new to programming and I'm trying to make a gui program that will allow the user to create text files. They will be prompted to enter what they'd like to save their file as and then they will be allowed to input text to that file . They will also be allowed to open their files to modify or view its contents. So to start things off, I'm making a prototype if you will.. I've been able to save to a file the problem occurs when I try to read/display it.

Main Class:

public class MainActivity {
public static void main(String[] args) {
// Access to other classes
WriteFile writer = new WriteFile();
ReadFile reader = new ReadFile();

[Code] ....

View Replies View Related

How To Read A File Than Display It Into Array

Jul 13, 2014

I'm new to java and I'm trying to figure out how to read a file like this:

Jan26081.5910211.79
Feb23301.5918221.79
Mar24261.5922101.79
Apr23751.6921431.79
May24001.6915381.79

And output the file and print it into an array with total under it.

View Replies View Related

How To Read Text File Into Array

Nov 17, 2014

I have to write a program for sorting an array of random numbers by the users choice. These random numbers are stored in a text file, which the user inputs, and is then stored into an array for sorting. I won't have a problem with the sorting algorithms, but I've never had to read a text file and store it into an array before

The text file has the numbers stored like so :
148
626
817
4
312
652
643
etc....

I gather that I'll probably have to user the Scanner for the user to input the text file name, but how do I store it to an array? So far I only have the bones of the program done, like so

import java.util.Scanner;
public class SortingAlgorithms {
public static void main(String[] args) {

[Code].....

View Replies View Related

Read Text File And Put It In 2D Array

Oct 25, 2014

I am trying to read in lines of text from a file then prints out the text. I only need one 2D array and can't copy from one array to another.This how the file looks like:

4 4
FILE
WITH
SOME
INFO

I have been able to read the file but when I am trying to run my program I have blank spacing instead of an array.

import java.util.Scanner;
import java.io.*;
public class Array {
public static void main(String[] args) throws IOException{

[code]....

View Replies View Related

XML Parser - Cannot Read Files While Running Program From JAR File

Feb 27, 2014

I have a program that is a XML-parser, and it works fine when I'm running it from NetBeans. But when I create a JAR-file and run the very same program, it cannot find the xml file. Consider this small program that addresses my problem:

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved