I've finally got Jexcelapi working and am able to read cell values and print them out. Now I want to use the data I read in from the spreadsheet. I'm able to read the data, perform math operations, and print it out again... but only one cell at a time. I'm building a simple card game. I want to read the ... |
public class Main { public static void main(String[] args) throws FileNotFoundException, BiffException, IOException, WriteException { Random randomGenerator = new Random(); int randomMap = randomGenerator.nextInt(695)+1; MapArray mapArray = new MapArray(); CardArray masterList = new CardArray(); CardArray silverAndGoldDeck = new CardArray(); int castlePosition = mapArray.buildMapArray(randomMap); masterList.buildMasterArray(); silverAndGoldDeck.buildSilverAndGoldArrays(1,2,castlePosition); [B][COLOR="Red"]mapArray.addDeckPositionsToMap();[/COLOR][/B] mapArray.displayMapArray(); masterList.displayMasterArray(); silverAndGoldDeck.displaySilverArray(); silverAndGoldDeck.displayGoldArray(); } } |
can any1 explain what the question want? it would be better if any of u guys would help me do lol 1) write method that return if and onli if an integer array contains duplicate items. test this method in a program. include another method that reads a list of numbers,terminate by -999 into an array 2) write method that return ... |
Hi guys! Ok so this is my first year in college and I am having a lot of trouble with my computer course which mostly consist of writing java programs. I am falling way behind in class and i have a mid term due next week. It is REALLY causing a lot of stress on me. I would usually go for ... |
class A6c { public static void main ( String[] Argument) { double [] a; double [] c = {2,3,4,5,6,7}; a = polynom(c); for (int i = 0; i < a.length;i++) System.out.println(a[i]); } public static double [] polynom (double [] a) { double [] b = {0}; for (int i = 0; i < a.length;i++) { b[i] = i*a[i]; } return b; ... |
I'm trying to put a filter over an image using arrays. For each given pixel, I need to take itself and the 8 surrounding pixels, multiply by the corresponding weights in the "coefs" array, and use the sum to set the new center pixel. So far, I've been able to make arrays for the pixel's 3 colors, and I have the ... |
I am new currently in school for programming, and have just started learning Java. My assignment is to write a program that will have the user enter 100 temperatures then it will calculate and output the average temperature, and the max and min temperatures. I am stuck on the input part, I need to know how to code the user's input ... |
|
Array for time table [code] import static javax.swing.JOptionPane.*; public class TTable { String timeTable[][][] = new String[7][8][2]; String day_name[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; String time_name[] = {"8am", "9am", "10am", "11am", "12pm", "1pm", "2pm", "3pm"}; String name = "a"; public int new_tt(){ String temp = "a"; for(int day=0; day<=6; day++){ for(int time=0; time<=7; time++){ temp = ... |
|
The no-arg constructor is supposed to be there. This is my appended code. The user should be able to input the amount of data to fill the fields how many times they want. They should also be able to view the data that they entered. Here is the appended code. Thanks Java Code: class Book { int num; static String isbn; ... |
|
Dear developers, I have a 2D array of an encryption String as seen below.. C H R I S T --> the header D F F G A D D A X D A D G A Z Z Z Z I have to sort the header ascending and form another array as seen below.. C H I R S T ... |
|
i have to write a program that uses an array and from the inputted numbers i need to sort the biggest,smallest,median and mean of the numbers entered into the array this is as far as i got Java Code: class array { public static void main (String [] args) { double num1, num2, num3, num4, num5; System.out.println ("Enter a number"); num1 ... |
|
|
|
You might want to scrap the idea of using arrays and instead create a couple of classes here, one perhaps called Award that holds a String for the award name and an int for the year, another, perhaps called AwardWinner that holds a String for the name of the person and an ArrayList for the multiple awards they've won, and then ... |
static void Reodering_sub( ){ reodering_output= new File [vector_SA.size()-1]; try { if (vect_min.size()>1){ vect_ordered_sub.setSize(test_after_filling_ordering.size()); Collections.copy(vect_ordered_sub, test_after_filling_ordering); Reodering_sub(); test_after_filling_ordering.add(vect_min.get(0).toString()); _2nd_min_element=vect_min.get(0).toString(); vect_ordered_temp.removeElement(next_point); next_point=_2nd_min_element; vect_min.remove(vect_min.get(0).toString()); FileWriter writer_rodering_out = new FileWriter(reodering_output[y]); for (int g = 0; g < vect_ordered_sub.size(); g++) { writer_rodering_out.write(vect_ordered_sub.get(g).toString()); //writer_rodering_out.write("\r\n\r\n"); }// end for (g) loop // close wrting into file writer_rodering_out.close(); } } } catch (FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) ... |
The assignment is to write a class to work with a rain averages program. The class I had to write finds the highest and lowest months rain total, calculates total for all months, and finds the average. My class compiles with no errors, the problem I am having is the program/main class file wont compile and I am not supposed to ... |
I have a program which takes user input (which is a full sentence) and returns it as an array. if the sentence the user has input include keywords which are predefined, an SQL query is run. my question is, if the user inputs a number, for example, 10000. how can i make sure that this amount is included in the SQL ... |
public int prefixLength(String si, String sj, int n) { n= Math.min(Math.min(n, si.length()), sj.length()); // find a posible valid n // find the length of the largest prefix of si and sj for (int i= 0; i <= n; i++) if (!sj.startsWith(si.substring(0, i)) return i-1; // that last char didn't match so i-1 return n; // all n characters matched } |
|
24. Arrays java-forums.org |
|
I am a new to programming and this is for a class, there may be a better way to accomplish the task but I do want to understand what is being taught. I am to create a class CollegeCourse, with three fields Course ID, credit Hours and Grade. & create get & set for each field; OK did that. Then I ... |
So I am trying to make a poker game and have already scrapped and starting rewriting my almost finished program because it was the first time coding a program and I did some pretty ugly things in there. But I am remaking it now and have a slight problem. I create my two hands and sort out the cards no problem, ... |
class Cercle { private double radius; public Cercle(double r) { radius = r; } public double circumference() { return 2 * Math.PI * radius; } public double surface() { return Math.PI * radius * radius; } public void afficher(String message) { System.out.printf("Circle %s \n", message); System.out.printf(" - radius : %6.2f\n", radius); System.out.printf(" - length of circumference : %6.2f\n", circumference()); System.out.printf(" - ... |
Hey i need help with a program that will use an array that takes in numbers and names and outputs the highest grade and the name of the highest grades holder. Here is what I have so far. import java.util.Scanner; public class ArrayGrades { public static void main(String[]args) { int[]Grade=new int[3]; int highestNumber = Grade.length; String[]name=new String[3]; int y=0; Scanner scan=new ... |
So, I just took this Java class and my teacher is possibly the worst alive and has no idea how to teach Java. But you know I'll spare you my sorrow and waste of money stories and get to my real problem. I need to make a program that uses an array, but the program has to be a "phone book" ... |
only the last two elements in the array determine the result string. example: if you check this list { 2, 4, 1, 3, 5 } in your method, the result is up_order and if you check this list { 2, 4, 1, 5, 3 } the result is down_order. the logic is wrong. |
I have been given a task and although some people may think im after easy answers i just wanna know what on earth im doing so very very wrong. Ive spent weeks on this and its still not working at all. I basically need options 4 and 5 to return the list of arrays for the students. the array itself seems ... |
Hi all, having a bit of trouble, could use some pointers. ASSIGNMENT: Write an application that allows a user to enter the names and phone numbers of up to 20 friends. Continue to prompt the user for names and phone numbers until the user enters "zzz" or has entered 20 names, which ever comes first. When the user is finished entering ... |
Hello, I am new to java and i have been dealing with a project right now, however i am facing a problem for which i can't find the solution. Java Code: import java.util.ArrayList; import java.util.Random; public class Realization { private int[] inGoers; private int[] outGoers; private int[] Weights; private int[][] tableA; private int[] Marked; private int[] CoverageIn; private int[] CoverageOut; private ... |
/public class kassoli { public static void main(String[] args) { // Create variables and initialize them. int intVal = 3; long[] longArray = new long[5]; for (int i = 0; i < longArray.length; i++) { longArray[i] = i*i; } System.out.println("Before Mystery call:"); System.out.println("intVal: " + intVal); System.out.print("longArray: "); for (int i = 0; i < longArray.length; i++) { System.out.print(longArray[i] + " ... |
i am sorry, i am a beginner in Java, and i did not really understand all what you posted let me give an idea of what i am doing in my program, the program is to ask the user he enter a number of students. then the same number of textfields must be displayed. the user has to enter students names, ... |
public class ArrayOutput { public static void main(String[] args) { int[][] myArray = { { 1, 2, 3 }, { 4, 5, 6 } }; for (int i = 0; i < myArray.length; i++) { for (int j = 0; j < myArray[i].length; j++) System.out.println("Array[" + i + "][" + j + "] = " + myArray[i][j]); } } } |
Hi, I'm not exactly new to java but I do have problems every now and then, anyways I'm having a problem with this code: (code is shortened to not include excess code you don't need to know about) //code starts here public class points { String[] points; public points(Point3f[] pt) { for (int a = 0; a < getLength(pt); a++) { ... |
I am just learning java, and would appreciate help for the problem below: Given an array of ints, swap the first and last elements in the array. Return the modified array. The array length will be at least 1. Here is my solution, which does not work: public int[] swapEnds(int[] nums) { int[] answer; answer = new int[nums.length]; answer = nums; ... |
|
|
|
Hi there I have an assignment that I managed to to to a large extent. My problem is on how to code for a situation when the inPut numbers is null or empty. Please check the problem in it's entirety below: This method takes an array of numbers as input and returns the index of the largest number in that array. ... |
I made the code look lke one below but it gives me the following error Your code caused an Exception: java.lang.NullPointerException Comments: The code should handle the possibility that the input array is null. view source print? XML Code: 01 class StudentSubmission { 02 int indexOfLargestNumber(int[ ] inputNumbers) { 03 int startIndex =0; 04 int max = inputNumbers[startIndex]; 05 int indexOfMax ... |
hey thanks am tryin to hold 3 lines of values into a 2D array would i do this by import java.util.*; public class array{ public static void main(String[] args){ int num[] = { {50,20,45,82} {25,63,10,16} {12,3,45,82} }; or sumfing like this int array1 [] {50,20,45,82} int array2 [] {25,63,10,16} int array3 [] {12,3,45,82} |
I am working on a project that should allow user input and to store 10 midterm1 grades, 10 midterm2 grades, 10 final exam grades then add the 3 to find the minimum total grade and maximum total grade and display them to the user. I got the code running but it only allows 1 score input for each of the the ... |
47. array java-forums.org |
48. array java-forums.orgPlease help me finding the error on my program. As stated below it needs to display the factorial of each 10 value in array.. But when I run this program it only display 1 value and 1 factorial. Please help on this. Thanks :) //Write a program that will input 10 integers then display the factorial of each value in array ... |
49. arrays java-forums.orgJava Code: public static void main(String[] argv) { int[][] ia = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; System.out.println("Sum of first level: " + sumIntArray(ia[0])); System.out.println("Sum of this 2d array: " + sumIntArray(ia)); } public static int sumIntArray(int[] ia) { int result = 0; for (int i: ia) { result += i; } return result; } // And ... |
public void removePlayers(Player[] client) { String G = ""; for (int i = 0; i < numPlayers; ++i) { G = G + client[i]; } JOptionPane.showMessageDialog(null, G, "Player Info", 1); } i have set up this fubction as i want to clear all the data in the array. the info is all brought forward with the string and i want to ... |
51. array java-forums.orgYou need to show your code, show its input and its output and describe what is wrong with the output. Or if you're having problems with one part of the code, post the code for that problem and describe what you are trying to do. Can you describe what this statement does? It adds together the contents of two variables and ... |
Does anybody see any problems with this? This is just were I'm starting at trying to get some tiles drawn. I looked up tutorials on 2D tile based games and around the parts with arrays they all get kinda vague, so I'm trying to wing it. Thanks for the help with the array by the way. Java Code: import java.applet.*; import ... |
09-01-2010 03:18 PM #1 Paulious1 Member Join Date Sep 2010 Posts 1 Rep Power 0 Trimming of array Hi, I'm having a real headache with this project. I am trying to create a project that reads in a JPG file ( which is a scanned form) this form has an invoice number BKxxxxxx, see attached. I want the program ... |
Arrays can be useful if you have n elements of type T and you have to manipulate them. The value of n has to be fixed before you do the manipulations and the type T also has to be known in advance and the manipulation of the elements can't be done sequentially. To most people new to programming arrays are the ... |
public class Driver { int[] a; // A variable is declared. [] stands for the declaration of an array. But not initialize. That means in an array you've to define how many items you want to store in advance, before use. int lastItem; public static void main(String []args){ a[0] = 4; // THIS DOES NOT WORK ?? WHY ?? PLEASE EXPLAIN:confused:.... ... |
Hello! I'm new to java and im trying to figure out how to use a scanner for how much arrays you can select. I'm browsing through the forum and I'm pretty amazed how active and friendly the java community is. Anyways i have a file named Rectangle.java where all it does is calculate the area of the given input from the ... |
can someone help me with my code....:confused: I need to block if the input has the same value ... example: if i input 1 in array[1] and then input another 1 in array[2] it will block... plz help :( here's the code: Java Code: import java.util.Arrays; import java.io.*; public class Main { BufferedReader ui = new BufferedReader(new InputStreamReader(System.in)); public String yn; ... |
heres what I have so far, am i on the right track, here are my instructions and my code so far. Please help Make a class called HW1.java. In this class, write the following: A method called doubleArray that has an int array as an input parameter and returns an int array in which each element has been doubled. In the ... |
Problem with ragged array The problem I'm having is that I need to read the data from a file into a ragged array based on country region number. I have it in an array and was attempting to just read from the array but i keep getting an array index out of bounds exception. It's a small program so ... |
hi .Please help with this java array creation problem? for (int i = 0; i < 150; i++) { radius = r.nextInt(10) + 1; point = r.nextInt(3) + 4; x = r.nextInt(1300) + 5; y = r.nextInt(800) + 5; s = new Star(point, radius, x, y); s.draw(page); //stars[i] = new Star(point, radius, x, y); //stars[i].draw(page); stars[i] = s; System.out.println(i + "-> ... |
|
62. array java-forums.org |
Alright, so what I want to do is presenting an array backward... so if I have an array of length 10 (1,2,3,4,5...) I want them to come out as 10, 9, 8... I was thinking something along these lines: public class uppg1 { int[] array= {1,2,3,4,5,34,7,8,9,10}; int i; public void summa(){ for (i=0; i |
|
Problem with arrays Hello. I'm new to this forum and very new to programming in Java. I just started with arrays and now I have an exercise I need to complete. The goal here is to create an array of student's cvs and then: -insert a student ordered by name -list all cvs ordered by name -delete cvs with ... |
I have a text file from notebook that has 160800 values. I have successfully imported them into Java. What I need to do is cut the 160800 in half and I thought Java could do it easier and faster than me manually deleting half. Here is my code so far: package lab2; import java.io.*; import java.util.Scanner; public class Temp { public ... |
I try to make an account program (console), with a customer class and 2 account classes that inherit from an abstract account class. My problem is that I'm trying to store historic in an array, and I only get one value when I retrieve it. For example if I make two deposits to one account and then I want to print ... |
Hello all! I have an assignment to convert an infix expression in to postfix and I have to use an array rather than an actual stack, which I believe is the typical to do this process. I keep running into a problem when parentheses are in the expression and the array seems to replace operators with parentheses in the array and ... |
import java.util.Scanner; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; public class sorting { public static void main(String[] args) throws IOException, MalformedURLException { Scanner input = new Scanner(System.in); System.out.println("Please enter the name of the Sorting file: "); String file = input.next(); File sort = new File(file); Scanner scan = new Scanner(sort); while (scan.hasNextLine()) { String line = ... |
Say we have a simple array like this: class test{ public static void main(String[] args){ int arr[] = new int[10]; for(int i=0;i<4;i++){ arr[i] = i; } for(int j=0;j |
Java Code: public abstract class Asset { private int serialNum; private double value; private String descrip; public Asset(int serialNum, double value, String descrip) { this.serialNum = serialNum; this.value = value; this.descrip = descrip; } public void setSerialNum(int serialNum) { this.serialNum = serialNum; } public int getSerialNum() { return serialNum; } public void setValue(double value) { this.value = value; } public double ... |
Im trying to make a method to filter an array say array1 has these contents 10 20 30 and array2 has 11 30 the array values are entered by the user so both arrays can be any length The method would take in these two arrays then return a new array, which has the contents of array1 plus any new numbers ... |
73. Arrays java-forums.orgHi I am trying to solve an assignment question on Arrays... Pls see the code that i have written so far. Is there an alternative to System.exit(0) statement? import java.util.*; public class Computer { static String name; static int size; static int speed; static String make; static double price; static int quantity; public Computer(String n,int s,int sp,String m,double p,int q) { ... |
74. Arrays java-forums.orgpublic class arraysReversed { public static void main(String[] args) { // input from user Scanner input = new Scanner(System.in); // Declaring our variables and setting up the array double[] values;//Intializing the Array values = new double[10];//Assigning 10 integers for the array to hold //Ask the user to enter 10 integers System.out.println("Please enter ten numbers."); values = input.nextDouble(); } } |
hello every one I'm making a code to calculate the mode (most frequent value or values in an array ) assuming we have only one mode ,The code I made is giving the lowest value if it is repeated even if the actual mode is the maximum value so i expand the code with adding more lines to do the same ... |
76. Array java-forums.orgclass AR1 { public static void main(String[] args) { String copyfrom[]={"Hello", "this" , "is " ,"a", " copy", "example"}; String copyto[]=new String[7]; System.arraycopy(copyfrom,0,copyto,0,6); System.out.println("the copi String at 0 : " + copyto[0]); System.out.println("the copi String at 0 : " + copyto[1]); System.out.println("the copi String at 0 : " + copyto[2]); System.out.println("the copi String at 0 : " + copyto[3]); System.out.println("the copi ... |
can anyone write in psuedocode for me..Dont know how to start.1. Rotating array contents. Write a Java program that rotates an array of integers by the number and direction entered through the command line. For example, given lst={1,2,3,4,5,6}, your code will return: command> java rotate 3 right before l={1,2,3,4,5,6,7} after l={5,6,7,1,2,3,4} command> java rotate 2 left before l={1,2,3,4,5,6,7} after l={3,4,5,6,7,1,2} |
public class bolhex{ void bubble(int v[]) { System.out.println(" entrou"); for (int i = v.length - 1; i >= 1; i--) { for (int j = 1; j <= i; j++) { if (v[j - 1] > v[j]) { int aux = v[j]; v[j] = v[j - 1]; v[j - 1] = aux; } } } return v[]; } public static void ... |
import java.io.* ; class ArrayMaximum { public static void main ( String[] args ) throws IOException { int data2[][] = new int[][] {{3, 90, 5, 8, 1}, {1, 4, 4, 129, 13, 12, 58, 77, 12}, {9, 1, 13}, {0, 2,0,50, 75, 77, 3, -1 }}; int sum =0; int max = data2[0][0]; for ( int row=0; row < data2.length; row++) ... |
//Expand the array to double its current size if the queue is full and //reallocate the array private void expand() { int newSize = 2*size; String[] newData = new String[data.length]; int j = head; for(int i=0; i |
|
Hi, I'm new to java. Need help. My array always adds to 0. I need to be able to add numbers and then do some calculations with it. Calculate average, highest and lowest lap etc. However, it always adds to 0. I have this code so far: package reversegear; public class ReverseGear { public static void main(String[] args) { int lap; ... |
my array is an attribute of the class Movielist and contains objects from the class Movie; moviedatabase is an instance of movielist I have an "open" function and I want this to empty my array and then write new information imported from a file I know how to import information to add to my array, but in this case I must ... |
i dunno why i keep receiving cannot find symbol in the command prompt.. =( i could not compile because of the one in bold... here is my codes.. can help me find out if got anything wrong with it? private ArrayList librianList; private ArrayList L1Hrs; private ArrayList L2Hrs; public LibrianManager() { librianList = new ArrayList(); L1Hrs = new ArrayList(); L2Hrs = ... |
package project12; /** * * @author David */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //create a table 3x3 double [][] firstTable = new double [3][3]; double [][] secondTable = new double [3][3]; double [][] sumTable; sumTable = addTables(firstTable, secondTable); double [][] sum ... |
Hi there, I'm relatively new to java and I have this one little problem which is probably quite simple, but I cant seem to get my head around it and solve it. What I am trying to do is eliminate duplicates in my array. Basically I want the user to be able to input 5 numbers, then I want it to ... |
Hi all, basically, I want to save data from an array to a file, and then be able to load it again. The data comes to the array from a tokenizer, so I want to put the data into the file after it has been passed to the array from the tokenizer. Thanks in advance. Java Code: public void stringTokenizer(String a) ... |
arrays are going to be my singlehanded downfall. I need to understand inside and out by 2weeks. Everything i can get my hands on to read about them seems brief and short but the hw problems are in depth and detail. I've tried to practice programming but thats shooting in the dark if i dont really understand them..any help would be ... |
89. Arrays java-forums.orgHello there. I writing a program which uses arrays and for loops. In this program, it will ask the user to input their names and whether they are under 16. The data they entered will be stored in two arrays, adults and children. In the end it will print an invoice listing names with the amount and also the total. For ... |
Hello, and welcome to the forum. So in essence what you've done is to give us your entire assignment without asking a question and without showing any evidence of effort on your part, and I'm afraid that in this situation there's not much that we can do for you other than to direct you to a tutorial or two. I suggest ... |
Hello! I was wondering if it is possible to in an array to move all the elements that have the value zero to the last position in my array, and then print it out. ex. 1 2 0 4 5 to -> 1 2 4 5 0, i started to write the code but it didnt seem to work. for (int ... |
Array's not being found. Sorry for so many post's. I wish I could give back but unfortunately I'm not experienced enough to give good advice. Anyway can't figure out why my array's are not being found. Any help would be great full. This program is not finished but I am kind of stumped on this part. Please any suggestions ... |
93. Array java-forums.orgI need to make an array using primitive array so I cannot use the class ArrayList. At the moment I initialise my array as follows: array = new new String[100]; But my array will need to hold hundreds of thousands of strings, so is there a way I can make the array of maximum size? Or, to expand its size each ... |
Hi guys, I'm new to methods and having a problem passing the results of an array to a display method, the simple program is to enter four saving account balances and return the array + the fixed rate bonus. I can use display methods with single variables, it's displaying the array that is throwing me! here's the code: Many thanks! Java ... |
So im supposed to select the cigar and county, then put in how many boxes I want to purchase. The applet then calculates the sub total, sales tax and the total price. The code below runs so you can see how the applet is supposed to be setup minus the calculations code which is what I dont know how to do. ... |
import java.util.Scanner; public class ArrraySample { public static void main(String[] args) { String[] lastname = new String [10]; String[] firstname = new String [10]; int []age = new int [10]; Scanner input = new Scanner (System.in); int n = 0; for (n = 0; n < 3; n++) { System.out.println("Input no" + (n + 1)); System.out.println("Enter last name"); lastname[n] = input.nextLine(); ... |
Hi, I have a project that I have to create a separate class, then read the data from a file into an array of objects. I am getting an error here. Then I have to list the data of the array (as is), then sort it both alphabetically and numerically, which I have not even started because I cannot even get ... |
Hi, I think what you're looking for is a two-dimensional array which is indeed possible in java. Basically you can create a blank 2d array like so: whatComesHere[][] myArr = new whatComesHere[3][3]; This would create in that array three arrays each with the capacity of three separate values. Also you can create 2d arrays like so: whatComesHere [][] myArr = {{1,2,3},{4,5,6},{7,8,9}}; ... |
If you want to read an int you call the method nextInt() but you type, say, 123. The nextInt() method reads and returns 123 but it leaves the character in the input buffer. The nextLine() method reads all characters up to an character. There still is such a character in the input buffer so the nextLine() method happily reads ... |
Hello, I am trying to write code to store integers (scores), print them out, and then display the number of scores entered. However, if you enter 3 integers it displays the 3 you entered, 2 zero's, and then tells you you entered 4 scores?! Im very confused here and have tried various if statements, loops, decrementors, etc and I am still ... |