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


ADVERTISEMENT

Hurricane Java Project - Unknown Format Conversion Exception

Mar 9, 2015

I am having some issues with errors. Here is my code...

import java.io.*;
import java.util.Scanner;
public class StormChaser {
public static void main(String[] args)
{
// Constants
final int MAX_STORMS = 319;
 
[Code] .....

I am having issues with these error messages.... I have tried a couple of different things with each error but haven't been able to figure it out.

Exception in thread "main" java.util.UnknownFormatConversionException: Conversion = '1'
at java.util.Formatter.checkText(Unknown Source)
at java.util.Formatter.parse(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.util.Formatter.format(Unknown Source)
at java.lang.String.format(Unknown Source)
at Storm.toString(Storm.java:98)
at StormChaser.DisplayStorms(StormChaser.java:141)
at StormChaser.main(StormChaser.java:53)

View Replies View Related

Create A Java Program That Can Read Specific Data Within Csv File To Work Out Averages

Aug 7, 2014

i am fairly new to java but have made a few projects so i do know most aspects that would allow me to complete the task its just i have been stuck at the same place now for 2 days.The project is to create a java program that can read specific data within a csv file to work out the averages etc. The csv file is a database of different weather stats . an example of the first 12 months of the csv file is below..

[CSV FILE]

year ,month,average rainfall etc

1946 15.70.616108.131.5
1946 28.23.56111.871
1946 38.82932.9 102.9
1946 414.16.3029.2 150.5
1946 513.96060.7 143.6

[code]...

I know that once the data is indexed i can than use a double to find the average of the 12 specific pieces of data and so on. once this is complete i should than be able to transfer the data to a simple graph.

View Replies View Related

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 View Related

Extract Information From Java Project

Mar 4, 2015

I should do, for my academic project, draw from a java project some information, for example, the class name and the relative method, and for each class even the package name where the class is. The information found must be saved an XML files...

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

Java Servlet :: Read Data From Excel File To Table

Oct 19, 2014

If I want to load data in excel file into table. what is the best way to do it?

View Replies View Related

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

I/O / Streams :: Unable To Read File Using Google Guava Resource Library In JBehave Project

Jun 25, 2014

I'm getting an IllegalArgumentException returned when I try to get a file using guava library.

I previously had the function working when the file was in a different location, before I switched to running JBehave, my steps run but it fails to find the resource, even after I've moved it.

The code being executed is (this worked previously before using JBehave):

String xMLTemplateFileName = "OBOE-confirmation"
public static void setXMLTemplateFile(String xMLTemplateFileName) throws IOException {
URL url = Resources.getResource(xMLTemplateFileName+".xml");

The file I'm looking for is in the root folder for src/main/resources and also src/test/resources, previously I had it within a completely different location before I switched over to JBehave. I've tried it within a subdirectory in the same locations too.

I've recently updated the pom.xml to try to include the location required.

Extract from pom is below:

<!-- JBehave Build Details -->
<build>
<pluginManagement>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>

[Code] ....

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

How To Load XML File Inside Of Java Class File In Netbeans Project

Feb 26, 2015

try {
File configFile= new File("C: Documents and SettingsstudentMy DocumentsNetBeansProjectsCDASsrcconfig.xml ");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName("config");

[Code] .....

This code is working properly but i have use path like this

File configFile= new File("srcconfig.xml");

Instead of system directory path i have to use path inside of project but i am getting an error-cannot find the specified file...

View Replies View Related

Data Read From File And Being Placed Into Arrays

Feb 8, 2015

I am creating a program where it reads the data inside a file and then places this data into arrays. The file I created has numbers 1-30 in it, file named, testing1.txt .

I am unable to post my code, it redirects me to a 'Page not found' page.

The problem with my program is a variable that I have initialized, is being said its not being initialized.

View Replies View Related

How To Read In A File And Extract Data

Nov 15, 2014

I am supposed to read in a file and extract the data. I am trying to add a Long into an Array that I initialized. So this is how my method looks like :

Java Code:

public void readOSMWay(File osm){
try {
Scanner output = new Scanner(osm);
while(output.hasNext()){
String line = output.nextLine().replace("^s+","");
if(line.startsWith(" <way")){
Road way = new Road(line,true);

[Code]...

I am having problem with the else if block. I am supposed to add all the Long values into the array.

error: Java Code: The method add(Long) in the type ArrayList<Long> is not applicable for the arguments (String) mh_sh_highlight_all('java');

View Replies View Related

Error In Program To Read Int Or Float Type Data From Keyboard

Aug 9, 2014

Here is a code and error .....

View Replies View Related

Use Data Read From File To Create Instances?

Sep 10, 2014

"Write a program (save the program as ProductInventory.java) that will read data about 5 products from a text file (Products.txt. The program should use the data read from the file to create instances (objects) of Product.java(Use Product class as a Reference Type)."

I'm yet to discover how I will get the info from the textfile using scanners but I don't know how to "create instances of a reference type".

This is the code of Product.java that came with the exercise.

public class Product {
private String productCode = "";
private String productName = "";
private int quantity;
private String supplierName = "";
private String supplierAddress = "";
private double price;

[Code] .....

By the way, the exercise also required me to use the abstract class ProductLister. To be clearer, the text file is kinda like this:

54643
Rizer Mouse
Mark5s Merchandising
Marquee Mall
4
205.50
23412
Acer Ultrabook
JohnJade Merchandise
Cornal City
2
62200.00
93112
Dell Ultrabook
Octagon Marketing
Cornal City
3
68900.00
22126
Macbook Air Pro
Computerware Services
San Beda, Chad
2
93500.00

View Replies View Related

To Decrypt Data - File Containing Keys Is Not Being Read

Aug 27, 2014

I am developing a java code using netbeans for encryption decryption by RSA algorithm. Swings and file handling play a major role in these code. My encryption code is working nicely but the code for decryption is not since keys file is not being read. That is why variable mod and pri are getting null values and the following error stack is coming. I know where the problem is somewhere in void readkeys() function but cannot solve it.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at java.math.BigInteger.modPow(BigInteger.java:1579)
at rsakeydecryption1.RsaKeyDecryption.decryption(RsaKeyDecryption1.java:167)
at rsakeydecryption1.RsaKeyDecryption.read_output(RsaKeyDecryption1.java:294)
at rsakeydecryption1.RsaKeyDecryption.actionPerformed(RsaKeyDecryption1.java:330)

[Code] .....

My code for decryption is

package rsakeydecryption1;
import java.math.BigInteger;
import java.util.Random;
import java.io.*;
import javax.swing.*;

[Code] ....

View Replies View Related

Best Way To Read Data From CSV File Then Compare And Display

Jun 13, 2014

I have 3 csv files as follows -

author file columns - emailID | firstname | lastname
books file columns - title | isbn | author_email | description
magazine file Columns - title | isbn | author_email | releasedate

I need to display -

1) Based on the ISBN display all books and magazines
2) All books and magazines by an author
3) All books and magazines by title

I am using Buffered reader as of now -

String csvFileToRead = "csvFiles/authors.csv";
BufferedReader br = null;
String line = "";
String splitBy = ";";

[Code] ....

I am confused about how to proceed with multiple files. Here are the approaches that i have considered -

1) change string csv csvFileToRead to a string array -

String[] csvFileToRead = {"data/autoren.csv", "data/buecher.csv", "data/zeitschriften.csv"};

Pass each index each time to a method returning all rows but getting stuck with DS to use. I think ArrayList wont suffice since i need separated data. Should i use a 2D array? Do i need to read and store data in a DS in order to achieve the goal?

2) Should i make 3 different classes with getters and setters for authors, book and magazine?

View Replies View Related

How To Read Data From Random Access File

Jul 10, 2014

I have a random access file stream. I have below code I want to written data that is currently pointed by pointer till the end and display that data on System.out Stream but it is not working my code is

//Create a Random Access File
java.io.RandomAccessFile random=new java.io.RandomAccessFile("D:/input.txt","rw");
//Position the pointer to a seek
try {
random.seek(300);
long pointer=random.getFilePointer();
System.out.println("Current Pointer is:"+pointer);
int a;
while((a=random.read())!=-1) {
System.out.println(a);
}

Where am I wrong? Although it is returning actual position of pointer in pointer using

View Replies View Related

Assembling Database Project From A Downloaded Project Zip File?

Apr 12, 2014

i downloaded a sample database code of an online payroll system. How can i assemble it to know how it works.
the files include php and mysql files. it is to build an online payroll system

View Replies View Related

Where Is Jar File In Java Project

May 27, 2014

As a brand new with Java I've created a small "Hello world" program using eclipse.

I would like to create an exe file from this application. Therefore, I need the jar file.

I can't find such a file with that extension in the folder where I saved the java project.

How can I manage this file?

I know it is a very basic issue, but as I mentioned it is the first "Hello world" test...

View Replies View Related

Read CSV File From Disk And Manipulate Data Inside

Nov 17, 2014

I need to read a csv file from the disk and manipulate the data inside. My problem is that if the csv (excel format) contains "" in any of it's values the whole string line gets saved/displayed incorrectly . For example for the line in the csv file :

1,393275,57319 57321 57323 57325 57327,5_5,200000,393277,57329 57331 57333 57335 57337,3_3,200000,400000,"gi,gi",,,,,,BASS/2.4,,1

it gets read in java as :

"1,393275,57319 57321 57323 57325 57327,5_5,200000,393277,57329 57331 57333 57335 57337,3_3,200000,400000,""gi,gi"",,,,,,BASS/2.4,,1";;;;

instead as :

1,393275,57319 57321 57323 57325 57327,5_5,200000,393277,57329 57331 57333 57335 57337,3_3,200000,400000,"gi,gi",,,,,,BASS/2.4,,1

My code is :

String csvFile = "resources/testcsxs.csv" ;
String l = "";
try {
BufferedReader cz = new BufferedReader(new FileReader(csvFile));
while ((l = cz.readLine()) != null ){
System.out.println(l);
}

What am i doing wrong , how can i read a csv file (excel saved) without getting "" added incorrectly ?

View Replies View Related

How To Read Data From Text File And Place Into Array

Nov 15, 2014

I'm trying to figure out the necessary code for reading integers from a text file, then placing them withing the two-dimensional array I have created, and then finally printing the array using a nested for-loop. I have attached the file I would like to read from. I'm having trouble figuring out how to reference the text file with the integers, and also how to properly create a dynamic preface for each row of the array. I want the preface to display as "Week #: ", with # being the row number. I tried to create an integer to be used that way, but NetBeans tells me whatever integer I declare has already been defined in method main. I know I need to use scanner to read the file. I would like the output to display like this:

Quote
Temperature Data

Week 1: 73 71 68 69 75 77 78
Week 2: 76 73 72 72 75 79 76
Week 3: 79 82 84 84 81 78 78
Week 4: 75 72 68 69 65 63 65

View Replies View Related

How To Make Java Project A WAR File In NetBeans

May 10, 2014

I am suppose to submit my project as a WAR file but not sure how to do it.

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

I/O / Streams :: Reading From And Writing To A File Then Read Again Including Data Written

Oct 11, 2014

I'm having a bit of trouble with using the Scanner and the Printwriter. I start with a file like this (1 = amount of Houses in the file)

1
FOR SALE:
Emmalaan 23
3051JC Rotterdam
7 rooms
buyprice 300000
energylevel C

The user gets (let's say for simplicity) 3 options:

1. Add a House to the file,
2. Get all Houses which fullfil requirements (price, FOR SALE / SOLD etc.) and
3. Close the application.

This is how I start:

Scanner sc = new Scanner (System.in);
while (!endLoop) {
System.out.println("Make a choice);
System.out.println("1) Add House");
System.out.println("2) Show Houses");
System.out.println("3) Exit");
int choice = sc.nextInt();

Then I have a switch for all of the three cases. I keep the scanner open, so Java can get the user input (house = for sale or sold, price = ... etc). If the user chose option 1, and all information needed is inputted and scanned, the House will be written to the file (which looks like what I typed above).

For this, I use try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("Makelaar.txt", false)))). This works perfectly (at least so it seems.)

If the user chose option 1, and all requirements are inputted and scanned, the Houses will be read (scanner) from the file and outputted. For this I use the same Scanner sc. This also works perfectly (so it seems atleast).

My problem is as follows: If a House has been added, I can only read the House(s) which were already in the file. Let's say I have added 2 houses, and there were from the start 3 houses. If option 2 is chosen, the first 3 houses will be scanned perfectly. An exception will be caught for the remaining 2 (just added) Houses. How can I solve this? I tried to close the Scanner, and reopening it, but apparently Java doesn't agree with this

View Replies View Related

Read Data From File And Place Larger Of Two Numbers In Corresponding Position Of Third Array

Apr 14, 2015

I am learning about arrays in my class and my professor has a habit of throwing in code without explaining. We are doing a program called storing largest numbers where we read data from a file and place the larger of the two numbers in the corresponding position of a third array. They are in 4 by 4 format. Here is the ending code

import java.io.*;
import java.util.*;
public class prog464aStoringLargestNums
{
public static void main(String[] args)

[code]....

View Replies View Related







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