import java.util.*;
public class TrafficIncidents {
public static void main(String[] args) {
Scanner s = new Scanner (System.in);
// Array for days
String [][] days = {{"Sat"},
[Code] ....
This is my output:
Day AM PM
--------------------------------
Sat
Sun
Mon
Tues
Wed
Thurs
Fri
5 1 1 2 4 1 0
Basically I want to align the AM traffic incidents under the heading "AM" but am not sure how to accomplish this. I am using separate arrays for all three of these types of information and need the info to line up with their respective titles.
I am trying to find the GCD, add, and remove the biggest and smallest fraction, however I am having trouble getting user input into the array and getting the information out of it (Variable f).
Scanner keyb = new Scanner(System.in); Fraction[] frak = new Fraction[7];
Main_Class try { for (Fraction f : frak){ // for each array in frak print f; System.out.println("Enter Numerator"); int num = keyb.nextInt(); System.out.println("Enter Denominator"); int den = keyb.nextInt(); f = new Fraction(num, den);
I'm trying to take the information from one 2d char array and put it into another char array but instead of traversing the array left to right I want the new array to be top to bottom.
Example fg would be fh hi gi
I'm having trouble getting the information from one to the other.
[code]public static char[][] translateIt(char[][] english){ int rows = english.length; int columns = english[0].length; char[][] chinese = new char[columns][rows]; for(int j=0; j < columns; j++){ for (int i = 0; i < rows; i++){ //chinese[i][j] = english; this is commented out because it didn't work. }//Ending bracket of columns for loop }//Ending bracket of rows for loop
return chinese; }//Ending bracket of translateIt[code]
I'm having trouble conceptualizing something. I will post the code, it's works exactly as it should. I create an array and Hash Map to display periodic table of elements information after allowing the user to search by element name or symbol. I want the user to also be able to add elements to the periodic table. I can't really conceptualize how I am going to do that with an array I've already created.
Here's code:
//Create element objects. //Here is where I create my "elements" array, and where I could like to prompt the user to add elements, if desicred. Element[] elements = {new Element("Hydrogen", 1, "H", 1.008,1,1), new Element("Lithium",3, "Li", 6.94,2,1)}; // //Maybe it seems if I prompt the user here to add new element names, symbols, weights, etc, I would be overwriting
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)
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
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:
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
I have been creating a Java program to track inventory using an array. I need to add a search function to it to take a term, input through a text field, and locate a matching instance within the array. How can I code a JButton to grab test input from a JTextField and search for it within the array then display the corresponding information? I also need to add buttons to add and delete items as well.
I am making a game in java and for the game board i want to fill the screen with blocks. to do this i stored objects of a class that displays squares into an array list and displayed the array list. however, when i do this all of the squares are drawn on top of anther at the final squares coordinates and i dont know why.
here is the code
// code for adding the squares into the array nt x = 0; int y = 0; int size = 10; static ArrayList<Map> map = new ArrayList<Map>(); //static ArrayList<Items> items = new ArrayList<Items>();
I am writing this program for my Java level 1 class. I am able to get it to compile and run, however nothing is outputted. Below are the instructions and the code that I have written.
Instructions:
Write an application that calculates and displays the amount of money a user would have if his or her money could be invested at 5 percent interest for one year. Create a method that prompts the user for the starting value of the investment and returns it to the calling program. Call a separate method to do the calculation, and return the result to be displayed.
Below is the code that I have written
import java.util.Scanner; public class Interest { //main method public static void main(String[] args) { originalAmount(); Scanner input = new Scanner(System.in);
I am reading from a database(SQL Server 2012) and storing that information in a ResultSet. I am then trying to display that information using a DataTable.
Here is my managed bean
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package clientspage; import java.io.Serializable;
[Code].....
The ID and the commandLinks are being displayed but the Client is not.
I have a empty JList in which I hit a button LOAD DATA which should load all the data. but once I load data i try to fill in the List but I keep getting errors.
String[] aos = new String[itrList.size()]; itrList.toArray(aos); //JList listFAIL = new JList(aos); //list = new JList(itrList.toArray()); //list.removeAll(); list.setListData(aos); JScrollPane s = new JScrollPane(list);
try { ByteArrayInputStream in = new ByteArrayInputStream( transferWorker.bOutput .toByteArray()); BufferedImage bufferedImage = ImageIO .read(in);
[Code] ....
But nothing is happening in the GUI. I have stepped through and bufferedimage contains the data, but its not being displayed. Whats happening is, an image is being transmitted to serial port of laptop, so i'm taking it in and storing it in a BufferOutputStream and then trying to open it in my GUI class.
I am getting blank page only. I created sample JSF project with Facelet in Eclipse. The source code contains basic page with header, content & footer. I refer the site Support-Eclipse . I deployed war into Tomcat. I am unable to find the problem.
I am trying to get items to display that would display in a command prompt now into a GUI. I am freaking lost at the moment, probably because I've been staring at this code for over a week now. I have included all the files that are necessary to run the program as an attachment for your own testing purposes. Should I be using a TextField to display the data from the CSV files? How do I get the data to be displayed? How would I get it to be displayed based on the different files Staples (newSTPL.csv), Apple (newAPPL.csv), and Microsoft (newMSFT.csv)?
Java Code:
import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * DataAnalyzer Class * This class instantiates the methods from the ReadFiles Class and Calculations Class.
I have html code that use form and the result displayed with display tag library the form forward to servlet page but when I use a javascript to change value of hidden after returning to html page the value of hidden input deos not change
Displaying the records in a table. I am looking for a group header to be placed above each printed table for its related category and subcategory, as well as, the no. of the records for each table to be shown at the top of the table.
The table contains columns for category, subcategory, name. ex:
Category Subcategory Name
CON Retail AAA
CON Wholesale BBB
SPEC Retail CCC
What I am looking for is the below layout:
Category/Subcategory (No. of records) –similar to a group header
Name – Country ..etc ----Table header
table records
Here is my code below:
<% //Retrieve the values from the DB while (rs.next()) { category_name1=rs.getString("category_name"); subcategory_name1=rs.getString("subcategory_name");
[code]....
The problem in the above code is that it is showing the group headers category & sub category multiple times and the count is incorrect.
Here I would like to collect automatically in a file ( txt) the characters displayed on the screen. I'm working on a system that the database is remote. To receive information, there is a terminal by which sends commands. The feedback is displayed only on the screen and you can only print. This is actually a terminal black screen, white character, such as command line "DOS" . The software can not export , or access to the database or other means of information retrieval .
I explored the track of the OCR . But the result produced is not consistent with the captured picture. How can I do this? I have no other tracks ....