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);
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;
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?
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();
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.
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.
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 ?
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.
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?
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?
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
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.
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.
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 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);
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?
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)
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.
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();
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.
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.