Drawing A Graph Based On Stock Values From 2 ArrayLists?

Apr 19, 2015

[URL] I made a program that takes 2 stock values by URL tickers, and now I need it to draw a graph with the values for the 2 stocks, so they can be compared visually. So far my idea was to create 2 arraylists that consist of the values for each stock, so that I can draw the graph so that x always move with 1 step, and y0 is the first coordinate, and y1 is the second, and after that y1 is the first, y2 second etc.

View Replies


ADVERTISEMENT

Text Based RPG Game - Working With Multiple ArrayLists

Feb 22, 2014

I have come across an issue with arraylists. I am writing a text based RPG game as something to start with ...

Initially I had a single zone which was all stored in an arraylist and everything was working in regards to the player moving around. The problem I now have is how to add further zones to my game. Ideally I would like an arraylist for each zone, and would use the below to create each arraylist

public static ArrayList<RoomsClass> castleMap = new ArrayList<>();

The problem I now have is how to handle the player moving, initially with a single zone/arraylist I could reference that arraylist directly

public void findRoomCoords(int ID) {
for (int i = 0; i < castleMap.size(); i++) {
if (castleMap.get(i).roomID.equals(ID)) {
PLAYER.setCurrentRoomZone(castleMap.get(i).roomZone);
PLAYER.setCurrentRoomX(castleMap.get(i).roomX);
PLAYER.setCurrentRoomY(castleMap.get(i).roomY);
PLAYER.setCurrentRoomZ(castleMap.get(i).roomZ);
}
}
}

My initial thought was to use a getter/setter to remove the reference of castleMap from my movement code in order to access different arraylists, however this is where things have fallen over, I can't seem to work out how to get the arraylist name to change, depending on the outcome of the setZoneMap() method.

public void setZoneMap() {
switch (PLAYER.getCurrentRoomZone()) {
case 0: {
zoneMap = Castle.castleMap;
break;

[Code] ....

View Replies View Related

Stock Program - Stop User From Entering In Textfield And Display Message When Stock Is Low

Jun 29, 2014

I'm trying to make a stock program that stops the user from entering in textfield and displays a message when stock is low. There's just 2 problem the entered value by the user is only decremented twice then the total stock resets for example with SofaTotal and the if statement doesn't work:

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import java.text.DecimalFormat;
import java.util.Arrays;

[Code] .....

View Replies View Related

Creating Analog Clock Based On Certain Values

May 3, 2014

I'm working on a Java/Android program that takes a number input (for example, hour = 7 and minutes = 30 for 7:30AM), and then expresses it on an Analog clock. (hour hand pointing to 7 and minute hand pointing to 30 minutes) ...

How can this be done? Would I need a lot of image files? How to start ...

View Replies View Related

Stock System In Java

Jan 6, 2015

I'm making a stock system for the heck of it,so everything was going great until I hit the loop I am trying to use a for loop to add stock to the stock system,any way the question is maily about loops.How come I cannot declare a variable outside a loop and assign a value to it,for example I can declare as follows and I will not get an error,

for(int i=0;i<10;i++){
System.out.println("example");

}

but in my code(and yes its the only error I get I tested it) I get an error and can only declare and assign a value inside the loop,the reason for this is because I wanted to get the value from another class and use it in the loop ok so heres the code from both classes.

public class mainn{

public static void main(String [] args){
stock first = new stock();
int internal;
internal = first.wanted;

[code]....

View Replies View Related

Map That Shows The Stock Of Some Company

Dec 16, 2014

Is there anyway i could clean this up. ??

package map;
import java.io.*;
import java.util.*;
public class Map {
public static void main(String[]args)throws Exception{

[Code] .....

View Replies View Related

Java MultiThreading Stock

Feb 13, 2014

I am doing a multi threading program . I am unable to get the output i want. I have no compilation error . But I cant get the result I , Null exception. This is my Test program

import java.util.*;
public class Test
{
public static void main (String[]args){
int totalShares = 0 ;
double totalCost = 0.0;
String name = "FCS";
double profit = 0.0;

[code]....

View Replies View Related

Stock Database Query Class

Dec 14, 2014

I have a Stock Database query class, it compiles and runs well. Thing is when i enter a user, it shows a user stock information but it repeats showing the same user in the command prompt. the repetition is so fast, you can't see the information. All i wanted was the application to show a user's info, then asks you to enter another user again and so forth. Here is the code

import java.io.*;
import java.sql.*;
import java.util.*;
public class StockDatabaseQuery {
public static void main(String[] args)throws Exception {
String userID;
String firstName;

[Code] ....

View Replies View Related

Stock Tracker Application - Column Bot Found Exception

Dec 13, 2014

I have Stock Tracker application running, everything works just fine, but when i hit the List Users button, i get an SQL Exception which says "Column bot found". I tried searching for the exception from the internet, but the answers didn't suit my needs. below is the Stock Tracker DB i think the exception might be coming from.

public class StockTrackerDB
{
private Connection con = null;

// Constructor: makes database connection
public StockTrackerDB() throws ClassNotFoundException,SQLException

[Code] ......

View Replies View Related

Write A Small Program That Will Calculate Gain / Loss Of Sale Of Stock

Jan 24, 2014

I am trying to write a small program that will calculate the gain and/or loss of the sale of stock. The program will ask the user for the number of shares, the purchase price and the selling price. I am pretty sure that the errors is coming from my calculations in the program.

import java.util.Scanner;
public class investmentCalculator {
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
//User input for number of shares
System.out.print("Enter the number of shares: ");
double shares = input.nextDouble();
 
[code]....

View Replies View Related

ArrayLists Objects Checking

Jun 27, 2014

I have to make ask for 2 houses or more (INSTANSED CLASS, with 2 ints ) with the same size(int ), but i they cant use the same door number(int). how do i check in my ArrayList that they have different numbers while not caring about different size? .

The ArrayList is in a class called system. I dont know if i should try to Override the equal or try something else.

View Replies View Related

Using Iterators To Compare ArrayLists

Sep 15, 2014

The question states:

>Suppose that aList and bList are instances of java.util.ArrayList. Use two iterators to find and display all the objects that are common to both lists. Do not alter the contents of either list. Write the segment of code assuming that the objects are of type String.

If my understanding is correct, I need to create two Iterators (one for aList and one for bList) to compare both ArrayLists and I should output any value that appears in both lists.

This is my attempt at it:

import java.util.ArrayList;
public class Test {
public static void main(String[] args) {
ArrayList<String> aList = new ArrayList<String>();
ArrayList<String> bList = new ArrayList<String>();

aList.add("One");
aList.add("Two");

[Code] ....

The output:

`One`

`Two`

It stops there. It's clear that my loop is wrong, but I don't really know how to go about fixing it.

View Replies View Related

Use If / Else Statement That Depends On Which Of 2 ArrayLists Contain Object

Sep 9, 2014

I have two arraylists. One is personalContactList. The other is businessContactList.

1. I want to take user input that references an object attribute (int),
2. Use it to determine which object is referenced,
3. Find the "type" attribute of that object,
4. Determine which arraylist the object belongs to, based on that type,
5. Use the if else/statement to print out some attributes that depends on which arraylist the object is in.

I believe the code successfully does 1-3, and probably 4. But there is a hangup on 5. I get an indexoutofbounds execption. Which I'm not sure I understand very well.

Here is the code--it's part of a switch statement:

case "c": {
//some code here prints out a list
boolean b = false;
int g; 
while (b == false) {
  Scanner detailScanner = new Scanner(System.in);
System.out.print("Enter a number to see details: ");
 
[Code] ....

View Replies View Related

User Inputting Objects Into ArrayLists

Feb 25, 2014

I'm new to java and up until now whenever I have created an object it has been via the BlueJ interface. I would make an object manually and then manipulate it with my methods.

I have made a basic program which adds objects into arraylists via the BlueJ interface. However I now need to prompt a user to enter a string which should create the specific object and add to its ArrayList.

Is there a way to create objects without manual specifying the parameters? I can provide some of my code if it is needed I am trying to make a crude version of Plant vs Zombies for an assignment.

I am aware of the scanner class but I only know how to prompt a user but I feel like if I can figure a way to create the objects I can dynamically I can associate the string inputs to the proper arraylists.

View Replies View Related

Between Two ArrayLists / How To Find Which Elements They Have In Common

Apr 6, 2015

I have two ArrayLists and I want to compare them for common elements, and based on the result I want to update the first Arraylist to only have these elements. sort of like the opposite of RemoveAll() which removes elements in common and keep the ones that are unique. so far I thought of using for loop and .contains() in case it was fault,element not present, remove from list. but I was wondering
in what other ways, perhaps APIs i can use to do that?

View Replies View Related

Code Which Adds Marks Into 2 Different ArrayLists

Jan 27, 2014

I have this piece of code, which adds marks into 2 different arrayLists, one for homework marks, and one for examination marks..

ArrayList<Double> homeworkMark = new ArrayList<Double>();
ArrayList<Double> examinationMark = new ArrayList<Double>();
boolean markCheck = true;
do{
//
the purpose of this try catch is to make sure that the entered mark is a valid number. If the program encounters an exception markCheck will become true and the loop will begin again asking the user to enter the marks. If the marks are all encountered correctly markCheck will be false and the loop will end.

try{
for (int i = 1; i <= amountAssignment; i++ ) {
sc.reset();
System.out.print("Homework Mark for Assignment " +(i) + ": ");
homeworkMark.add(sc.nextDouble());
System.out.print("Examination Mark for Assignment " + (i) + ": ");
examinationMark.add(sc.nextDouble());
markCheck = false;
 
[code]....

View Replies View Related

HashMaps / ArrayLists - Diamond Operator?

Jul 8, 2014

So I am learning HashMaps/Arraylists and I can't really understand the diamond operator or what it's for. Take the following code for example: Why could we not just do this without the diamond?

Java Code:

import java.util.HashMap;
class Untitled {
public static void main(String[] args) {
HashMap<String, String> map = new HashMap<String, String>();

map.put("California","Sacramento");
map.put("Oregon","Salem");
map.put("Washington","Olympia");

System.out.println(map);
}
} mh_sh_highlight_all('java');

View Replies View Related

Using Command Pattern For Undo And Redo In ArrayLists

Apr 15, 2015

So I have a program where you can log in and add/remove friends to and from the friends arraylist. Also I can like a certain thing and that thing will be stored into the likes arraylist. I'm asked to make undo and redo options for whichever action I do.I want to add apple as a friend. After that when I select the undo option, I can undo that action so apple wouldn't be my friend. How I can approach this with a Command Pattern when the input is whatever name or word I inputted to store into the friends arraylist?

I did some research and found that using a command pattern could be my best bet since this has to be done under the Facebook Class I already have. I decided to add parts of what I have ...

In the driver program

Facebook facebook1 = new Facebook();

if (userInput == 6) {
System.out.println("Login");
String operand1 = getOperand("What is the Username? ");
String operand2 = getOperand("What is the Password? ");
System.out.println("Enter a friend to be added. ");
String operand3 = getOperand("What is the Username? ");
facebook1.friend(operand3);

[code]....

View Replies View Related

Linking Elements Of Two Arraylists Together For A Bubble Sort?

Jun 13, 2014

I have been doing a program that allows the user to input students names and numerical grade values. I have already completed 3/4 of the program but am stuck on the bubblesort method as this is what it requires:

The program must have an indefinite loop, which prompts the user to select a sorting criterion or to end the program, and must also use bubble sort. Note: The user may either select name or grade as the sorting criteria. The program must use bubble sort to sort that data according to the specific criteria and then use another loop to display the data. This process must continue until the user ends the program.

My problem is, while i can easily do the bubblesort, where to look on how to link elements of the two arraylists I'm using (one for grades, one for names) so that when the user decides what sort they want, the individual's name and grade stays together.

View Replies View Related

Populate DB From Another Using ArrayLists And Arrays - Index Out Of Bounds Exception

Mar 16, 2015

I have an issue with an IndexOutOfBoundsException. I am trying to populate a db from another using arraylists and arrays. I can get the data but the program fails when trying to run the inserts. I am trying to perform SQL in batches of 5. I have added a comment to the failing line.

/*Set in code at beginning*/
ArrayList<String[]> privacyList = new ArrayList<String[]>();
ArrayList<String[]> statementBuffer = new ArrayList<String[]>();
 
/*Some sql is performed and the following String array is populated*/
while (rs.next()) {
String[] row = new String[55];
resultSetIsEmpty = false;
row[0] = rs.getString("ID");

[Code] ....

View Replies View Related

Save Class With Arrays So As To Reload Them Again And Hold Onto List Of Objects Within Those ArrayLists

Dec 7, 2014

I have a class with static ArrayLists to hold objects such as Members,Players etc.I want to save the class with the arrays so as to reload them again and hold onto the list of objects within those ArrayLists.

The ArrayClass

import java.io.Serializable;
import java.util.ArrayList;
public class ArrayClass implements Serializable {

[code]....

The arrays within the ArrayClass are empty when i reload the application.I cant tell if the arrays are being properly saved or is it in the reloading from file???

View Replies View Related

How To Plot Graph

Nov 13, 2014

I am new to java. I wana create a java program that can plot a graph for that I've already written this:

/ x axis would be the ,,elemszam" from 0 to 599;
y axis would be ,,resz_xy"
double sum_xy=0;
double g=10000.0;
double z_xy;
double xy=0;

[Code]...

--- Update ---

Actually i'm using netbeans...

--- Update ---

and the datas are coming from a text file...

View Replies View Related

In And Out Degree Of A Graph

May 2, 2014

I have this code for reading a text file and printing out information about the graph, the program works perfectly but I need to figure out the in degree and out degree of the graph if it is an directed graph. So my question is how would I go about implementing that? I know what in degree and out degree does but in terms of the code I'm not so sure, so I'm thinking if the case of vertex 0,1 the first vertex comes before the second vertex so that would in an in degree right? But how would I do that?

graphs.txt
6,1
0,2 0,4 1,4 1,5 2,1 2,3 2,5 3,2 3,4 4,1 4,5 5,1 5,3 5,2

import java.io.File;
import java.util.Scanner;
 public class Vertices {
public static void main(String[] args) throws Exception {
@SuppressWarnings("resource")

[Code] ....

View Replies View Related

Generate Bar Graph From Data

May 22, 2014

I need to generate a bar chart given the data that is in main. The relative performance of each sorting algorithm with respect to time, number of comparisons, and number of swaps for each data set (e.g., 50,000 –400,000 random integers). Each algorithm will have 5 bars corresponding to the 5 data sets. The height of these bars will depend on the performance of the algorithm for that data set.

I know how to write a bar with normal values like integers but for this I'm not sure because the values for instance comparisons and swaps are not given they are calculated. I just need to know what steps to go about doing that, you can even express them in pseudocode or even just explaining it I don't need the code, I think. Here is the main

public class Main {
public static void main(String[] args){
int t= 50000;
int t2=100000;
int t3=200000;
int t4=300000;
int t5=400000;

[Code] .....

View Replies View Related

Adjacency List Graph

May 4, 2014

I'm trying to read a text file of a graph and print information about the graph including the order and size of the graph, rather it is a directed or undirected graph, if it is directed the in and out degree, and the and a list of all vertices for which it is adjacent. The problem is the adjacency list is just printing out the list of vertices instead of the adjacency list. Is there something in my code that is problematic? Also I'm unsure of how to go about the in and out degree

"graphs.txt"
6,1
0,2 0,4 1,4 1,5 2,1 2,3 2,5 3,2 3,4 4,1 4,5 5,1 5,3 5,2
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner; 
public class AdjList {
private Node first; // beginning of list

[Code

View Replies View Related

Java Graph - Cannot Find Symbols

Feb 27, 2015

I am taking an algorithm class and i am having some problems trying to get this program to work.The file name is Graph.java

package graphs;
import java.util.HashSet;
import java.util.ArrayList;
public abstract class Graph

[code]....

View Replies View Related







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