I had a phone interview with a guy and I thought it went well. At the end he told me to send him a Java program that reads from a file containing a list of integers, one per line, and prints out all the pairs that sum to 8. I thought I made a pretty good algorithm that finds all the pairs that...
I am using JAVA to generate a graph of the E field close to a conducting plane. The result which I want to graph is $$E_z (x)= \frac{Q}{2\pi \epsilon_o} \left(\frac{d}{(x^2+d^2)^{3/2}} - \frac{h}{(x^2+h^2)^{3/2}}\right).$$
The code is below:
import java.io.Console;
import java.io.*;
import...
Hi This is a question somewhere between maths and numerical methods...
I am using the algorithm for Nelder Mead found here:
http://www.ssl.berkeley.edu/~mlampton/neldermead.java
in java. It works nicely with the two example functions - rosen and parab.
I am trying to adjust it to my function...
I'm an undergraduate, and I have a scholarship to help do research with one of my professors. He's assigned me to learn Java and how to program Android apps.
I have absolutely no programming experience. It seems like they expect me to get it down in a couple of weeks, but there is just so...
I have recently begun physics graduate school. My own programming background is in Java, but I haven't done much computational physics of a caliber that required me to implement things *well*.
My research advisor states that most of the numerical simulation that takes place in our field...
I'm joining my school's FIRST Robotics club, and our supervisor has said that we will be using Java to program our robot this year.
I have self taught myself Python and enjoyed it, but does any pone have any advice/tips/links for helping learn Java? I know it's a whole different animal...
Hello everyone. I am a little confused as to how I should organize if else statements in java. Here is an example from my Leap Year program:
if (x<1600) {
System.out.println(setError);
} else if (x>2013) {
System.out.println(setError);
} else {
if...
Hi,
I'm running Internet Explorer 10 and when I go into manage add on, I see Java is enabled. However, when I try to run the applet in this link
http://www.certicom.com/index.php/33-experiment-an-elliptic-curve-model-over-fp
about elliptic curve cryptography, I'm unable to run it. I...
Hi, I'm doing a mini-project in java that involves some nasty calculations with complex numbers- particularly with complex numbers in exponents. Thus far, I've had success using this class: Complex.java . The problem that I'm encountering involves taking the natural logarithm of a complex number...
Homework Statement
Create a class which contains the following:
a)instance variables for the complex number. For x+yi, x and y are the variables.
b)constructor to initialize these variables.
c)methods to return the real and imaginary parts of the complex number
d)method to compute the...
I have problem with installing and uninstalling Java. Some of my work cannot be completed without a working Java. I tried to uninstall Java(TM) 6 Update 37 , it gave me an error message:
Error 1723. There is a problem with this Windows Installer package. A DLL required for this install to...
Homework Statement
See code below:
The Attempt at a Solution
I am simply trying to get the code to work: When I try to compile, the terminal says that apparently the package ptolemy.plot.* package does not exist and so does not recognise statements like PlotFrame etc.. Why is this...
I am writing a basic program using Java. The function is to break up any number the user inputs into smaller values, the catch is that these smaller values have a maximum usage and the overall result has to use the combination with the highest amount of values. I am figuring out the code just...
Ok, I have a java app that allows you to choose a class (wizard/elf) and is supposed to give a random amount of health (an array with 10 values) and 25 points of health. When I run the program it gives me the memory location from the array and not the value. I know I am missing something simple...
want some sites to teach me how to develop a simple web-based search engine that demonstrates the main features of a search engine (web crawling, indexing and ranking) and the interaction between them.
Using Java :confused:
Just wondering if the Java experts here could help me. As part of a project I'm making a function rand9() that returns a pseudo-random number 0 through 9. The problem is that each time it's called I need a certain number to increment so that it can generate a new (not necessarily different)...
Homework Statement
So, we have a project to make a tic-tac-toe game and for bonus points we can make sure the player(s) can not enter the same position more than once. I can't think of a way to do this. I'm sure I need to use a 'for loop' or a 'while loop'.
I am using eclipse to write the...
For learning C and for references, " The C Programming Language" by Dennis Ritchie and Brian Kernighan is an authentic. Which book should I refer to if I need to learn Java the same way?
I'm currently trying to learn java and I've managed to pick up most of the basics from tutorials and stuff on the internet (loops, conditionals, defining functions etc.).
However none of them provide a good explanation of OOP and how to use it in java, except for a very trivial example like...
[Java] Can't figure out this "Illegal start of expression" error
From my Java code:
while (info.substring(j, j)) != " ") {
name += info.substring(j, j);
j++;
}
gives an "illegal start of expression" error
Homework Statement
Problem:
Tele-Annoy, a telemarketing company has asked you to write a program that when given the area code to dial, generates the next three potential telephone numbers, and then outputs them to the screen for one of their sales representatives to call. Use the area code...
I have 2 possibilities, non of them worked:
PD: I am sure that all the methods inside this method(s) are correct and I am sure that the program's GUI is refreshing effectively.
public void metodo1()
{
for (int i=0; i<(perros.size()); i++){
for (int j=perros.size()-1...
Hi,
Wanted to ask you guys how does Java know what specific parameter to take into a method if the method name has to be only - let's call it - "internaly consistent" (meaning the parameter in the head and the body have to be the same).
E.g. if I pass a value to the method:
private int...
Hi,
I wanted to try to use cmd to compile and run a program in java. I have sucessfully compiled it. The compiler is working properly (C:\new> javac output the compilers functions), but I'm always getting the same error: "Error: Could not find or load main class hello".
When I specify the...
Homework Statement
Just trying to finish up this assignment, no errors. I run the program, enter a value and a percentage, then click calculate. Program just runs, never displays results. Check my code below, let me know if something is wrong.
Driver:
package ch7pc1;
import javax.swing.*...
Hello and thank you for putting up with this noob question.
The directions on the website or anything I have found on the internet are not very descriptive.
I have downloaded Eclipse and Java JDK version 7 and successfully installed both of the applications on my computer, but I must have...
Hi PF,
I'm working on a program that requires measuring how long it takes a given computer to process a certain task, but am having trouble coming up with algorithms that won't take most computers a trivial amount of time to perform. The only one I've got so far is recursively computing...
Homework Statement
You are to write a robust program (i.e., a public static void main()) that accepts a file pathname (e.g. 'c:\foo\bar' or '/home/jblow/' under UNIX) as input and then calculates and prints the size of that filesystem object:
java FileSize c:\foo\bar
123625 bytes
The purpose...
I am using the netbeans IDE
All I am trying to do is print out to the screen, but I keep getting this error.
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: system.out.println
at mysqlconn.mainhgf4.main(mainhgf4.java:19)
Here is my...
Homework Statement
I'm given a maximum time, a time step (or interval) and I'm supposed to form an array from 0 to the maximum time going up by timestep each time.
double tMax; //maximum time
double tStep; //time interval to go up by
Homework Equations
Our teacher told us to use the...
Hey guys, I have an ArrayList<String> al = ArrayList<String>(); and I have a textbox, the textbox allows a user to enter a word and that word will be added into the ArrayList.
When I print the list out it looks like this
[Cat, Dog, Mouse] can you please write out the for loop that I need...
I have a package with all the classes needed to perform the functional recquirements (calculations, etc.). It's working perfectly. The "main" class is "FinalesCopaMundo"
I have another package with all the classes needed to perform the GUI. The "main" class is "InterfazFinalesCopaMundo".
I...
Can anyone tell me how to get the Textbox to the bottom of the applet window?
public void init(){
setLayout(new GridLayout(6,0,5,5));
al = new ArrayList();
addNewWords = new JButton("Add Word");
displayAllWords = new JButton("Display Words")...
Hi all. I am currently working on quicksort and have written the following code and gives "almost" good results. I am not too fond of the data structure I have chosen but it is too late for me to change. Lesson learned. Can anyone help me debug this thing. I have been at it for a while. Anyway...
Homework Statement
Homework Statement
I need to write a class that represents a circle object and includes the following;
-Private Class variables that store the radius and centre coordinates of the object.
-Constructors to create circle objects with nothing supplied, with just a radius value...
If I have a program where I need to return an array, is it possible that I only return the array with the length of what was added to it?
What I mean is I have an array that gets filled up with letters but it doesn't always get completely filled up.
Is there a way I can only return the...
Homework Statement
I have to write a JAVA program that will compute and display (via the ptplot package) the solutions for the damped harmonic oscillator (x against t) in some given range for t. The solutions vary depending on how gamma and omega are related. The instructions given were:
1)...
Hi PF,
I am trying to write a program that utilizes a for loop that skips the current iteration (via continue) if it takes too long (for instance, longer than 20 seconds, else it finishes the current iteration as per normal), but am not sure how to best do this.
Does anyone know of a way...
Hello,
I am trying to figure out what I did wrong and I couldn't figure it out.
here is the error code:
setMake(java.lang.String) in Automobile cannot be applied to ().
Class file:
import java.util.Scanner;
public class Automobile
{
private int num; //number of automobiles to...
Homework Statement
I'm working on a program that uses an ArrayList to hold a collection of UserID objects (which contains the first and last names, plus username and password).
When I add a new UserID to the list, I want to check to make sure that it is not already there.
This is the error...
I have:
public final static int NUMERO_ESCENARIOS=4;
escenarios = new escenario[NUMERO_ESCENARIOS];
having an error in the first line that says: Syntax error on token ";", , expected
but when I have:
public final static int NUMERO_ESCENARIOS=4 //semi colon deleted
escenarios =...
I'm getting this error
sun.awt.image.PNGImageDecoder$PNGException: crc corruption
at sun.awt.image.PNGImageDecoder.getChunk(Unknown Source)
at sun.awt.image.PNGImageDecoder.getData(Unknown Source)
at sun.awt.image.PNGFilterInputStream.read(Unknown Source)
at...
i have been learnin java for about two weeks. i have gone through simple programin and some other programs includin GUI through swing. till that i was working with single form programs that can be compiled by using "javac" and executed by "java" syntax.now to try better i downloaded a java...
Homework Statement
Hello everyone, I am trying to write a java program that asks the user to input a number n, and the computer calculates the nth Fibonacci number. I am supposed to use a loop to calculate the problem.
My question is, how do I set up the loop to calculate the nth...
Hello,
I just downloaded the Java Development Kit (J2EE) and during the install I was asked to configure something called Glassfish. I don't understand what Glassfish is for. Is it only for Web development? What does it do for me?
Hello all! So I am working on a Java program and we have introduced artificial intelligence to a missile that is hunting a flying aircraft in 2d. The purpose of the program is to compare 3 different guidance systems--pursuit, proportional, and parallel. I am stuck on parallel!
We have the...
Use a loop to read (charAt()) each digit (0/1 char) in the input string, scanning from right to left;
Use the loop to build the required powers of 2;
Use a conditional statement to deal with 0 and 1 separately;
Debug using simple input, e.g. 1, 10, 101, and print intermediate values in...
import java.util.Scanner;
import static java.lang.System.out;
import java.util.Random;
public class wolf {
public static void main (String[] args){
int hitpoints = 100;
int damage = 40; //un numero cualquiera, solo para hacer una prueba
Scanner keyboard = new Scanner(System.in)...