ValidAccounts - Array Will Not Fill Properly

Dec 8, 2014

My validAccounts array has a null value in it when i print it. How to do this.

I am NOT allowed to use bufferedReader or ArrayLists. This must be done with loops.

import java.util.*;
import java.io.*;
public class ATM2 {
public static Scanner kbd;
public static final int MAXSIZE = 50002;
public static void main(String[] args) {
kbd = new Scanner(System.in);

[Code] ....

View Replies


ADVERTISEMENT

Array Will Not Fill Properly

Dec 8, 2014

my validAccounts array will not fill properly and has a null value in it.I added a print statement that prints the contents of the array and it is filling correctly but the very last value is null. I am supposed to be asking the user for a account number and password and it is not printing out correctly due to the fact that the array is not filled correctly.

import java.util.*;
import java.io.*;
public class ATM2 {
public static Scanner kbd;
public static final int MAXSIZE = 50002;

[code]....

View Replies View Related

How To Fill Array Of Points

Oct 10, 2014

I need to write a program but I am having hard time filling an array of triangles...we are suppose to have 3 different classes..1 class of points..1 class of triangles and 1 main method which apply all those..here what I have been come up so far for the point class which I believe is good..

public class Point {
private float x;
private float y;
//Making x equal to the x coordinate and y equal to the y coordinate like on a graph
public Point(float xCoordinate, float yCoordinate) {
x = xCoordinate;
y = yCoordinate;

[Code] ....

Now here is my question how I am suppose in the main method fill an array of triangles for 100 triangles or less?

View Replies View Related

Fill 2D Array With No Duplicates

Nov 2, 2014

THE PROGRAM DOES NOT HAVE ERRORS. FILL THE 2D ARRAY WITHOUT DUPLICATES VALUES. AND DISPLAY IF THE ARRAY IS MAGIC SQUARE OR NOT.

View Replies View Related

Randomly Fill 2D Array In Constructor

Dec 7, 2014

I must fill a 2d array randomly and then apply methods to the array. However i keep getting an out of bounds exception no matter what dimensions i use. I have a test and a class program.

import java.util.*;
import java.lang.Math;
import java.util.Arrays;
import java.util.Random;
class SummerStats {
Random rand = new Random();

[Code] .....

View Replies View Related

Bingo Board - Having Array To Fill A Grid

Dec 16, 2014

I am attempting to make a 5x5 bingo board. My array generates 75 numbers(15 per bingo letter) and displays them in a random order. What I am having trouble figuring out is how to fill the 5x5 grid with 25 numbers from my array. And yes, my code is probably much longer and much more redundant than it needs to be. Also, I think I'm using cells and grids terribly wrong (possibly the entire java language) but I'm not sure.

import java.util.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.event.*;
import java.util.ArrayList;
import java.awt.GridLayout;
import javax.swing.JButton;
public class bingoboard extends JFrame

[code]...

View Replies View Related

Fill A Panel With Seats

Jun 13, 2014

We get a database and some DAO classes. We had to fill a ShowPanel with different shows being given in a theatre, and then when you choose from this you get several dates. Then when you click a date, the seatings appear in the SeatPanel. I got the first part with the shows and dates. But Im stuck at getting the seatings.We have a controller class which calls the shows+dates (this happens in one method). But i always get a nullpointerexception for the seatings. (this happens in a different method). I think i just don't know how to link the chosen show+date with the seatings.For the moment i have

public ArrayList<Seats> getSeating() throws SeatingException{
Show s = shows.getName();
ArrayList<Showdate> showdate = s.getDates();
ArrayList<Place> seating = new ArrayList<Place>();
try{
for (Showdate sd : showdate ){

[code]...

The given class PlaceDao has a static getInstance() method and an ArrayList<model.Place> getSeating(model.Showdate showdate) method.In the next stage i have to try and fill the panel with the seatings, but first i need to be able to call them.

View Replies View Related

How To Fill A String With Characters Randomly

Jul 5, 2014

I need to make a string filled with naughts and crosses like this one : "xxx ooo xox". There are 3 groups separated with a space. how to fill the string randomly ?

View Replies View Related

Using JDK To Fill In Spread Sheets In Excel

Jan 27, 2015

I would like to make a small gift for my dad and i have a spreadsheet and i would like to make a small program that asks information and the puts it in the right column in the spreadsheet .For example i ask how many children do you have in your class and you answer 7 and that number goes into the spreadsheet.

View Replies View Related

Fill Different Size Boxes With Bags Most Efficiently

Jan 23, 2015

I have to write an example program to fill boxes most efficiently with bags. All bags are the same size. The boxes come in Large, Medium and Small. Large boxes hold 20 bags. Medium boxes hold 10 bags. Small boxes hold 5 bags. I am getting input from JOptionPane input dialog box and then parsing that input to an integer.

I have to fill the large and medium boxes completely. I am not sure how to do this without an if statement. I can use one, but we have not covered it in class, so I am skeptical about using one to solve the problem. If I just divide the input number with integer division, I'm not going to get the remainder, right? So I'm thinking that I can mod my input number by 20 (the number of bags the user inputs) and then mod that number by 10 and then mod that number by 5, would that work?

View Replies View Related

Swing/AWT/SWT :: Fill JTable From Database With SwingWorker?

Sep 26, 2014

Why this code is not working/my JTable won't updated after i click the button

import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.sql.ResultSet;

[code]....

View Replies View Related

How To Deal With Exam Like PDF - Fill In Oval Image

Feb 1, 2015

So, let's say I have a pdf that looks like an exam or anything that has answer choices and an oval to fill in.

So, if I want to create a program that fills in some of those ovals, I would first need to find the coordinates? I can use something like gimp?

And once I have those coordinates, what do I do? Like do I extract the oval image and replace it with a filled in one? Is there a library that lets me do this - also lets me set the size to make sure the new filled in oval image is the same size?

View Replies View Related

Swing/AWT/SWT :: How To Fill Text Fields With Selection From JList

May 2, 2015

I have an addressBook GUI where I have a JList that populates with the contacts names, and once I double click a contacts name I'm wanting to fill the textfields with the contacts corresponding data.

ex) ContactType: Family (enum), Name: Zoidberg, Address: 111 Space Drive, City: New York City, etc...

I've got it to where I select open from the JMenu, it populates the JList, but once I select a contacts name, all the textfields are populated, but only with the contacts name

ex) Name: Zoidberg, Address: Zoidberg, City: Zoidberg, etc....

What am i doing wrong here, and how can i fix it to where it fills out the correct data?

Here's my code so far:

public class AddressBookGUI extends JFrame {
private final int WIDTH = 450;
private final int HEIGHT = 300;
private JLabel currentlySelected;
private JTextField contactTypeTextField;

[code]...

I'm certain the logic is messed up near the end where i set all text fields to the index, because no matter what field i want to fill it's at it's going to set it to whatever index I select, but I don't know how to fix it.

View Replies View Related

Write A Java Program To Fill Excel Spreadsheet

Jul 15, 2014

I have an excel spreadsheet, with a specific filename and location which doesn't change (e.g. C:/workbook.xls)What I would like to do is have a window open when I open an .exe file, and in this window is a bunch of check boxes, text areas and drop down boxes (I can implement these, that's about my level of JAVA)

Then, when I click on a button in this window (for example, a button which says "Save"), the data from all these boxes and menus etc. goes into specific cells in the excel spreadsheet. Or if certain values are selected from a drop down menu, then a bunch of cells are empty.

View Replies View Related

How To Fill Contents To Jtable Dynamically On Button Click

Dec 17, 2014

this is my code

private void showresultsActionPerformed(java.awt.event.ActionEv ent evt) {
Object dbs=db.getSelectedItem();
Object colls=coll.getSelectedItem();
String distances=distance.getText();
String skillss=skills.getText();
DefaultTableModel tb=new DefaultTableModel();
MongoClient m = null;

[Code]...

i have added the columns but how could i show up the change??

View Replies View Related

Unable To Fill Blank Squares On Minesweeper Game

Nov 12, 2014

I'm having trouble filling in the blank squares on a Minesweeper game. What I am trying to is, if a user clicks a square and that square(s) does not have a bomb in it, or adjacent to it, should be set to an empty square.

Here's my recursive method below:

public void revealZeros(){
for(int x = -1; x <= 1; x++)
for (int y = -1; y <= 1; y++){
Square zeroSquare = (Square)board.getSquareAt(xLocation+x, yLocation+y);
if (!(zeroSquare.SquareHasBomb)){
setImage("images/empty.jpg");
}
}
revealZeros();
}

I am traversing around the square that the user clicks on with the use of two for-loops. Getting the square at that location and then applying an empty square image. On that square.

The function should then recurse itself and go onto the next square, if the next square does not have a bomb or does not have an adjacent bomb.

I keep on getting an infinite recursion problem

View Replies View Related

Print Writer Won't Fill Output File / Blank Every Time

Apr 10, 2014

I am trying to write to an output file that the user names. I have flushed and closed the printwriter, so now I am at a loss. The console output works fine with the formatting, and the file is created, but I cannot get the file to populate. I have the following:

public static void main(String[] args) {

try
{
Scanner kb = new Scanner(System.in);
System.out.print("Input file: ");
String inputFileName = kb.next();
System.out.print("Output file: ");
String outputFileName = kb.next();
// Construct the Scanner and PrintWriter objects for reading and writing
File inputFile = new File(inputFileName);
Scanner in = new Scanner(inputFile);
PrintWriter out = new PrintWriter(outputFileName);

[code]....

View Replies View Related

JavaFX 2.0 :: How Does Fill Mode Work In GridPane Column Constraints

Jun 12, 2014

The following code uses a column constraint to specify that a column of labels should extend horizontally in their cell but they don't as you can see by looking at their border. My mistake or a bug?

import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;

[Code] ....

View Replies View Related

JavaFX 2.0 :: HTMLEditor - Default Size / Cannot Fill Full Screen

May 10, 2015

The code:
 
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;

[Code] ....
 
run (when window height > 700px ) :
 
HTMLEditor  default height is 670px, the other area (green color) is not filled,why?
 
HTMLEditor   高度总是670px, 怎么把HTMLEditor 填充满窗口?
 
这是一个bug吗?

is it bug?

View Replies View Related

Calculate Cost To Fill A Pool Based On Its Shape / Length / Width And Depth

Sep 17, 2014

This program is for a swimming pool filling service company. They charge 2 cents per gallon and $50 per hour to fill a pool. The truck can fill at a rate of 730 gallons per hour.

Create the Pool class that calculates the cost to fill a pool based on it's Shape, length, width and depth. (Input order is S L W D)

The pool class will need data fields for String shape, double length, double width, double depth, static double GallonsPerSqFoot = 7.4805, static double price per gallon = .02, static double FillingFeePerHour = 50.0, and static double FillingRate = 730gal/hr.

Create a No-Arg constructor and a constructor that accepts the non-static values, and has the methods: getShape, getLength, getWidth, getDepth, getGallons, getHours, getFillingFeePerHour, getHourlyCost and getTotalCost.

At the end of the class, create a main() method that asks for the input and returns the output based on the Pool class gets.. methods.

The shape options are oblong or rectangle. (A round pool would be oblong with the same width and height, a square pool would have the same width and height)

Formulas:
Rectangle cubic ft = length * width * depth.
Oblong cubic ft= ((Math.PI * Math.pow(width/2,2)* depth) +((length-width) * width * depth))
Gallons = cubic ft * 7.4805.
hours = total gallons/730.
Total cost = (total Gallons * .02)+(hours * $50)

Example Output
An oblong pool 18.00 feet long by 12.00 feet wide and 5.00 feet deep will use 6923.10 gallons of water and take 9.48 hours to fill. The total cost will be 612.65.

Here is my code:

import java.util.Scanner;
import java.util.*;
public class Pool
{
private String poolshape1 = "oblong";
private String poolshape1 = "rectangle";
private double length;
private double width;
private double depth;
private static double GallonsPerSqFoot = 7.4805;

[Code] .....

View Replies View Related

Interface Not Updating Properly

Mar 20, 2015

The program runs well , it adds the applet but it dosn't update the interface unless I press "_"(Minimize) . To be more clear , the object paints a spring wich goes through 4 stages , it is added to the JFrame but it dosn't uptade until I minimize the frame , that is when it goes to the next stage .

The main class which calls the spring to be added to the frame :

public class principal implements ActionListener ,Runnable{
JTextField field;
JFrame frame;
private class Action implements ActionListener {
public void actionPerformed(ActionEvent event) {
  frame.repaint();

[Code] .....

View Replies View Related

Swing UI Not Responding Properly?

Nov 27, 2014

Here's the code to my UI and it runs but output doesnot shows properly..

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.*;
import java.util.*;
import java.io.*;
public class LoginPage extends JFrame{
JLabel lblLoginAs;

[code]....

and when I hover over the Login Button its border gets distorted..

View Replies View Related

Images Not Displaying Properly

Nov 16, 2014

My code:

import javax.imageio.ImageIO;
import javax.swing.*;
import java.io.*;
import java.awt.*;
import java.lang.*;
import java.awt.image.*;
import java.net.URLDecoder;

[Code] .....

I my images (including the one I created) are all 32x32. I'm trying to get a player Icon and have them be on a field of grass. Currently, I just get:

(see Attached)

I don't know where my Images are rendering.

B = blank
. = grass
p = player

.
.
.
.
. p
.
.
b

View Replies View Related

OnItemLongClickListener Not Working Properly

Apr 19, 2014

I created a dialog file:

Java Code:

package com.example.classorganizer;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

[code]...

When I long click item in the list nothing happens. I get no errors at all and I believe that either I put the code in the wrong place or I missed something else that stops Dialog from starting.

View Replies View Related

Using HasNext Properly In Program

Apr 16, 2015

Why do I get an error on the hasNext line when I try to compile this?

public static void main(String args[]) throws Exception
{
BufferedReader infile = new BufferedReader(new FileReader( "woodchuck.txt" ));
HashMap<String, Integer> histoMap = new HashMap<String,Integer>();
String word;
while((infile.hasNext()) !=null) {
if(histoMap.get(word)==null)
histoMap.put(word,1);
else
histoMap.put(word, histoMap.get(word)+1);
}
infile.close();
System.out.print(histoMap);

View Replies View Related

Calculate Fuel Economy Of Personal Car In Terms Of Gallons Per Mile And Total Cost For One Fill-up

Apr 4, 2015

public class CarV5
{
// private instance variables
String Model1;
int endMiles1, startMiles1;
double gallonsUsed1, pricePerGallon1;
 
[Code] .....

When I try to compile the program, its telling me that it cannot find the Dist variable in the main method for calcMPG and calcGPM. I'm not sure if the methods are right for the calcGPM or calcMPG.

View Replies View Related







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