Print Table (array) Where Have X Axis And Y Axis?

Apr 12, 2015

I want to print a table (array) where I have an X axis and a Y axis. 16x11. My code is as follows:

int Windchill [] [] = new int [16][11];
{
{60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15} //X
{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50} //Y
};

The code doesn't work even though it's similar to

int Windchill [][] =
{
{60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15}, //X
{0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50}, //Y
};

if I remember correctly, the 2 are correct just written in different ways.

and I want it to print like this

{60, 55, 50, 45, 40, 35, 30, 25, 20, 15, 10, 5, 0, -5, -10, -15},
{ 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
5, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
10, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
15, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
20, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
25, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
30, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
35, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
40, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
45, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,
50, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0,}

where 0 is null (for now). I want to fill those in with a formula later, but I don't hardcoding them one by one is the most "efficient" way to do it

View Replies


ADVERTISEMENT

Moving Object In Y Axis

Jul 10, 2014

I just have one problem with a "car" program in java. The objective is to move the car in the direction it is facing. Moving forward in the normal position (when the angle is zero) means moving in the x-axis. Choosing to turn the car function (for example: 90 ) and then using the forward function should move up or down the car in the y-axis. However the y-axis is not working.

Car2 Demo.rar
JPGMoveforwardfunction.jpg

View Replies View Related

Pong Game - Y Axis Collision Detection

Jan 28, 2014

I have made a "Pong" game and how to check if the ball has hit the top or the bottom of a paddle, however I do know how to check if it has hit the left or right side:

Java Code:

if((BALL.getX() >= LEFT_BAT.getX() && BALL.getX() <= LEFT_BAT.getX() + LEFT_BAT.getWidth()
&& BALL.getY() >= LEFT_BAT.getY() && BALL.getY() <= LEFT_BAT.getY() + LEFT_BAT.getHeight())
&& (BALL.getX() >= RIGHT_BAT.getX() && BALL.getX() <= RIGHT_BAT.getX() + RIGHT_BAT.getWidth()
&& BALL.getY() >= RIGHT_BAT.getY() && BALL.getY() <= RIGHT_BAT.getY() + RIGHT_BAT.getHeight())){
BALL.increaseDX();
BALL.setDX(-BALL.getDX());
} mh_sh_highlight_all('java');

It seems as though I would use the same code for checking the top or bottom.

View Replies View Related

JavaFX 2.0 :: Chart Axis Changing Color

Mar 20, 2015

I'm struggling to change the colour of the X and Y axis. I can change the colour of the ticks and the tick labels in CSS... But not the axis themselves.

View Replies View Related

JavaFX 2.0 :: Panel Effect - Rotation Along Its Y Axis

Dec 14, 2014

I have a UI widget, like a table view for example, displaying real-time data. This table can be configured - so it has many properties. The way I would like to do so, is to have a small 'configure button', once clicked, would rotate the entire table along its y axis, and display another panel with checkboxes etc... So effectively, the hidden properties panel is revealed by rotation.

View Replies View Related

Which Axis To Increment / Decrement With Inclusion Of Speed Variable

Jan 30, 2015

if I move object A to one area of the screen I want object B to to move to object A's location but I also want object B to move at a fixed speed (movement variable). How do I go about doing this? Both the x and y coordinates of object B would need to know the coordinates of object A to calculate the distance between the two and to determine how much of which axis to increment/decrement (if that makes sense?) with the inclusion of the speed variable.In other words I'm just trying to create a homing object.

View Replies View Related

Swing/AWT/SWT :: Java2D Graph Plotting - Divide X And Y Axis With Frequencies

May 29, 2014

I am using Java 2D API to implement Graph plotting. I am able to transform and scale the origin upright.

Now, I need to divide the x & y axes with frequencies (Ex: On Y-axis: 0 10 20 30 40 etc ..) and then plot points (Ex: [34, 54] etc) accordingly.

Which methods to use or way out to make this implementation?

View Replies View Related

Drawing A Square In Quadrant I Grid - Axis Not Display Properly

Feb 3, 2015

Currently, I am trying to create a program that draws a square anywhere in a 15x15 Quadrant I (Coordinate plane) grid. I am stuck on trying to get the axes displaying correctly. This is the code I have thus far:

import java.util.Scanner;
public class Question2square {
public static void main(String[] args) {
// Axis variables
int yAxismin = 0;
int yAxismax = 15;

[Code] ....

Unfortunately, instead of drawing the 'L' shaped axes I desire, it displays an 'r' shape instead. I'm trying to figure out how to display the axis properly. I tried flipping the for loops but that didn't work. I don't see what else could be inhibiting this.

View Replies View Related

Vector Math - Calculate Equation Of A Plane That Would Rely On All Axis

Jan 27, 2014

I am running into some trouble with Line-Plane intersection, my method works, provided I am perpendicular to the plane I want to intersect. This is caused be the plane equation (with my given x, y, and z coordinates, the equation is -Z - 1 = 0). So the equation is only relying on the Z value of anything inputted. Is there another way to calculate the equation of a plane that would rely on all axis? Here is my current code:

Java Code:

Vector3f A = new Vector3f(0, 0, -1);
Vector3f B = new Vector3f(0, 1, -1);
Vector3f C = new Vector3f(1, 1, -1);

Vector3f v1 = new Vector3f(B.x - A.x, B.y - A.y, B.z - A.z);
Vector3f v2 = new Vector3f(C.x - A.x, C.y - A.y, C.z - A.z);

float[] i = new float[]{v1.x, v2.x};
float[] j = new float[]{v1.y, v2.y};
float[] k = new float[]{v1.z, v2.z};

[Code] ....

View Replies View Related

Calculate Distance Between Two Coordinates And Determine How Much Of Which Axis To Increment / Decrement

Feb 1, 2015

Basically I'm looking for a way to make one object follow another. For example, if I move object A to one area of the screen I want object B to to move to object A's location but I also want object B to move at a fixed speed (movement variable). How do I go about doing this?

Both the x and y coordinates of object B would need to know the coordinates of object A to calculate the distance between the two and to determine how much of which axis to increment/decrement (if that makes sense?) with the inclusion of the speed variable. In other words I'm just trying to create a homing object.

View Replies View Related

JavaFX 2.0 :: BarChart Axis Tick-labels Missing With JDK1.8

Jul 10, 2014

Currently I try to integrate a JavaFX BarChart into my existing Java application. Therefore I need a BufferedImage of my BarChart, so that I can render that snapshot on a Graphics instance.
 
I adapted the existing BarChartSample.java (Chart Sample | JavaFX Tutorials and Documentation) and removed all animations. The code itselfs works fine but I identified one problem -> my TickLabels are missing
 
The TickLabels are visible If I use JDK 1.7u51 but if I change to JDK 1.8u05.... than the stlye of my BarChart will be changed and my tick labels are not visible.
 
Did I missed something or is that a bug?
 
using JDK 1.7u51
[URL] .....
 
using JDK 1.8u05
[URL] .....
 
My adapted code is the following:

package barchartsample;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

[Code] .....

View Replies View Related

Nested For Loop - Print Out Table Of Angles (sin / Cos And Tan)

Oct 1, 2014

I am working on my java program it prints out a table of angles and the sin, cos, and tan. For extra credit he wanted us to use nest loops to create a space after every five lines. I have come real close to getting this to work but have a problem with the very end of the table. The table needs to stop at 180...

public static void printTable(double angle,double sin,double cos,double tan) { // Method to create a table for the values
for (double j = 0; j <= 180;) {
for (double i = 1; i <= 5; i++) {//loop to print five lines of code
angle = Math.toRadians(j);

[Code] .....

Here is the end of the output of the table:

175.00.0872-0.9962-0.0875
176.00.0698-0.9976-0.0699
177.00.0523-0.9986-0.0524
178.00.0349-0.9994-0.0349
179.00.0175-0.9998-0.0175
 
180.00.0-1.00.0
181.0-0.0175-0.99980.0175
182.0-0.0349-0.99940.0349
183.0-0.0523-0.99860.0524
184.0-0.0698-0.99760.0699

View Replies View Related

Write A Program To Print Out Fahrenheit-Celsius Conversion Table?

Oct 14, 2014

This is my program

import java.util.Scanner;
import java.text.DecimalFormat;
public class Lab6 {
public static void main(String[] args) {
int F;
double C = 0;

[Code] ......

output

0 1 2 3 4 5 6 7 8 9
0 degree Fahrenheit equal to :-00.00 degree Celsius
1 degree Fahrenheit equal to :-00.00 degree Celsius
2 degree Fahrenheit equal to :-00.00 degree Celsius
3 degree Fahrenheit equal to :-00.00 degree Celsius
4 degree Fahrenheit equal to :-00.00 degree Celsius
5 degree Fahrenheit equal to :-00.00 degree Celsius
6 degree Fahrenheit equal to :-00.00 degree Celsius
7 degree Fahrenheit equal to :-00.00 degree Celsius
8 degree Fahrenheit equal to :-00.00 degree Celsius
9 degree Fahrenheit equal to :-00.00 degree Celsius

I don't know why the program is not calculating the C degree ?

View Replies View Related

Convert 2D Array To String Using ToString To Print Array

Apr 19, 2015

Trying to convert 2D array to String using toString() to be able to print the array but when I try to use it I just get the memory location

public class Forest
{
private int h;
private int w;
private double p = 0.7;
private int[][] f;
Forest(int w, int h)

[code]....

View Replies View Related

Convert Array Of Integers To Array Of Characters And Then Print It Out

Feb 13, 2014

I have double checked this code over and over and I just can't find the problem.

What I'm trying to do is take a file and input it into an 2D array.

Ultimately, I should convert the array of integers to an array of characters, then print it out. The file contains a set of ASCII values.

After printing it out, I should then create methods to manipulate the image produced.

Using 2D arrays is a requirement for this exercise.

I think that somehow I'm overcomplicating this and the solution is a lot more simple than I think, but I can't think of what to change.

The error I am getting is:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 40
at main.main(main.java:17)

Java Code:

import java.util.*;
import java.io.*;
public class main {
public static void main(String[] args)
throws FileNotFoundException {
String[][] data = new String[22][40];

[Code] .....

View Replies View Related

New Method Array To String Or Just Print As Array?

Feb 20, 2014

I just tried to fill an array with some numbers, calculated by a other function.I just tried to print this array as array, but it doesnt work. Maybe its just about the main method.

public static void main(String[] args) {
ggT(5);
}
 
public static int ggT(int a, int b) {
 
while(a!=b){
if(a>b) {
a=a-b;
} else {
b=b-a;
}
}
return a;
 
[code]....

View Replies View Related

Basic Array Table Not Working?

May 9, 2015

My code is supposed to give the array index on the left and what is inside the array on the right, but i get nothing except the header? I am using eclipse.

public class Options{
public static void main(String args[]) {
System.out.println("Index Value");
int value[] = {1,2,3,4,5};
for(int add = 0 ; add <value.length ; add++) {
System.out.println(add + " " + value[add]);
}
}
}

View Replies View Related

Table Booking In Restaurant - Declaring 2D Array

Oct 29, 2014

import java.io.*;
public class Booking {
private Customer[] [] booking = new Customer [7] [tables];
private int count = tables;
private String restaurant;

[Code] ......

View Replies View Related

High Scores On Table - Shifting Elements In Array To The Right

Dec 7, 2014

I'm trying to write a program that asks a user how many high scores they want on a table, then the users types the inital highscores and is repeatedly asked to place more high scores on the table, which if larger than any existing high score, will take its place and shift the other scores down.

Although for the shifting and inserting of that next score the code just doesnt seem to be working, the insertScore function is where im getting the main exception, and im not sure why?

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class HighScores {
public static void main(String[] args) {

[Code] .....

View Replies View Related

JTable With ImageIcon - How To Use Array With 4 Values In Table Cell

Mar 22, 2015

I would like to create a JTable.
 
Each cell contains an array of 4 objects:

[0] ImageIcon
[1] ImageIcon
[2] Number
[3] Boolean

1) Once JTable is displayed, each cell display only [0] .
2) Later, based on user mouse click on cell, cell should display [1]
 
How can I use an array with 4 values in Table Cell?

View Replies View Related

Name / Zip Array Read And Print

Sep 22, 2014

Designed to store a first name (string), last name (string), and zip (int). Assume each line will contain two strings followed by integer each separated by tab. Then print.

I have my two class files (one for the individual and one for the array) and then my driver below. I think my only problem is my driver. I think I'm reading the data file wrong but not sure how exactly.

test in .txt file:

JohnSmith12345
JohnDoe12346
SueSmith09877
VeronicaVarguez67890
MuhammadMaliki54321

public class Person
{
private String firstName;
private String lastName;
private int zipCode;
public Person(String fName, String lName, int zCode)

[Code] ....

View Replies View Related

How To Print All Numbers Of Array In Java

Jan 1, 2015

This is my code

package com.arraydemo;
import java.util.TimeZone;
import java.util.concurrent.TimeUnit;
public class ArrayStructures {
public long[] theArray;
public int arraySize;
public ArrayStructures(int size)

[code]....

and i am getting this output

----------
! 1712 !2156|
----------
! 1713 !4583|
----------
! 1714 !3981|
----------

[HENRY: 6000+ LINES DELETED -- Isn't it a bit ridiculous hard to read when you flood a post with thousands of output lines?]

----------
! 4998 !3094|
----------
! 4999 !836|
----------
12:10:56

I am expecting Number to be print from Index ) but they are not printing ,why?

If I use arraysize like 2000 I am getting all number starting from 0 to 1999 .why?

View Replies View Related

Print Array Asterisk Bar Chart

Jul 6, 2014

I am trying to get this program to take 5 integers from a user and print a bar chart made of asterisks. The only way I've been able to access the values stored in the array is when my loops are nested, but this keeps my output from printing the way I would like it to.

It prints:
Enter a number:
2
**
Enter a number...and so on

I want it to take the values say(2,3,5,8,4) and do this:
**
***
*****
********
****

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int[] barArray = new int[5];
for(int i =0; i < barArray.length; i++){
System.out.println("Enter a number: ");
barArray[i] = in.nextInt();
for(int j = 0; j < barArray[i]; j++){
System.out.print("* ");
}System.out.println("");
in.close();
}
}

View Replies View Related

Print Duplicates Element Of Array

Apr 16, 2014

This code is not best way to find the duplicate elements in a given array. Any alternative method for an optimized code.

Java Code:

import java.util.Arrays;
public class Find_Dupliicate_ArrayElement {
public static void main(String[] args) {
int[] Array1 = {1, 9,8,1,2,8,9,7,10, -1, 1, 2, 3, 10, 8, -1};
// Store the array length
int size = Array1.length;
//Sort the array
Arrays.sort(Array1);

[code]....

View Replies View Related

Print 2 Largest Number In Array

Apr 1, 2014

Thought process : Sort the array and print the last 2 element of any given array.

Note /| Should not use any inbuilt Array.sort()

Java Code:

//Write a code to print the 2 largest numbers from the given Array {2,8,10,5,9}

package arrays;
public class biggest2numbers {
public static void main(String[] args) {
int[] A = {2,8,10,5,9};
//Declaring 2 variable
int Max1,
Max2;

[Code] .....

View Replies View Related

Sort Array List Print?

Nov 23, 2014

I am having an issue trying to print different types of arrays using one method. Eclipse tells me to convert my print method for each array type:

change method 'printList <e>' to 'printList(ArrayList<integer>)'
change method 'printList <e>' to 'printList(ArrayList<Double>)'
change method 'printList <e>' to 'printList(ArrayList<Character>)'
change method 'printList <e>' to 'printList(ArrayList<String>)'

I would like to accomplish printing all four different arrays using one print method. How to accomplish it or provide examples or links to examples?

import java.util.ArrayList;
public class SortArrayList {
public static class Sort {

[Code].....

View Replies View Related







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