Hi all,
Suppose on computer 4 different versions of java are installed.
(1) Depending on the path of java.exe we can open command prompt go to path /jdk_version/bin/java.exe and type "java -version" and know the
particular version, But we can't extract the output of the command "java...
I am supposed to write code to rotate an array 90 degrees to the left... so my question is, why is this code not rotating my array 90 degrees to the left?
thanks for any help!
public static int[][] rotateLeft(int[][] source) {
int[][] result = new int[source.length][source[0].length]...
Homework Statement
Write code to rotate an array...
Homework Equations
why is this code not rotating my array 90 degrees to the left? thanks SO much in advance!
The Attempt at a Solution
public static int[][] rotateLeft(int[][] source) {
int[][] result = new...
Hi, I have to do a homework assignment for my intro to computer porgramming class and i have to write a program that creates insult sentences. My professor gave us some code to start with and we had to fill in the functions(professor gave us the names of these functions and the name of the...
I'm new in java and
I'm trying to come up with a program that stimulates the bean machine(also known as Galton box)
Balls are dropped from the opening of the board. Everytime a ball hits, there is a 50% chance to fall to left and 50% chance to fall to the right. the piles of balls are...
Homework Statement
The first several numbers in the "Fibonacci Sequence" are 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Each number is formed by summing the two previous numbers. Define a method named prevFib that takes a non-zero Fibonacci number and returns the Fibonacci number that comes immediately...
Homework Statement
Define a recursive method named pow that takes two integers, x and n, and returns the result of raising x to the n-th power. Assume that n is non-negative.
pow(5, 0) ==> 1
pow(2, 10) ==> 1024
pow(-3, 2) ==> 9
Homework Equations
The Attempt at a Solution...
I'm a physics student in the penultimate year of my degree. I'm quite good at programming and was thinking this summer I'd put in 3 months of effort and get Sun Java Certification.
Would this be worth the effort? Would it be something which would be very attractive to a prospective grad...
I'm pulling my hair out with this problem. I have two bodies and I'm trying to calculate gravity between them. This is for a game, and there are actually three bodies currently, each frame, I check the distance each one moves due to gravity and store it in a cache (to simulate gravity acting on...
Homework Statement
To code a dots and boxes game variant. Basically I need to code the same game except instead of drawing lines you choose two dots to form a line. I would need MouseListener for clicking and entering/exiting dots, a graphics update for changing colors of the dots and...
Java or C++ - Threads HELP!
I need help with this program. I got five others to do and I won't have time to do it and it's apart of my final exam for next Tuesday, can somebody write this program:
Create 5 threads which share a file and
let "even" threads write to a file, and let "odd" delete...
Java or C++ - Threads HELP!
I need help with this program. I got five others to do and I won't have time to do it and it's apart of my final exam for next Tuesday, so here is my question I need:
Create 5 threads which share a file and
let "even" threads write to a file, and let "odd" delete...
I can't figure out how to get these 2 methods to work. In my assignment description it says
public BinTree getLTree()
Get a reference to the left subtree. If this is not possible to do then throw an IllegalArgumentException.
NOTE
This routine returns a BinTree, not a Tnode. You...
Hi all,
I've been trying to figure out how I can use the Scanner class in Java to pause my program and wait for the user to hit the return key. What I have now looks like this:
Scanner kbd = new Scanner(System.in);
kbd.next();
...
The thing is, the rest of my program won't run unless there...
i need to know what the error messege below means and how to fix it.
Exception in thread "main" java.lang.NumberFormatException: For input string: "z"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at...
I have run into a problem... The language filter we have been using is out of date and it periodically does not work. I was hoping I could get some help on making a new one.
The old one:
import java.io.File;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.net.SocketAddress...
Hi, i need to use a list class (provided and complete) and then use a Linkedlist class (need to add the methods) to get a stack going. I am having trouble with my remove from head method although I ain't too sure if my addHead method is right... I'd appreciate it if someone could look over my...
I have recently started to try to teach myself java and i can't get the keybord reader to work.
I'm a book thet's for java V1.3 but I'm using the newest version is that the problem? unless the book was wong then my program syntax should be fine. could anyone tell me what the syntax for the...
Has anyone here used this book? If you have, how would you rate it.
To my surprise many programmers seem to despise Schildt's books. One is usually directed to this page to make the point.
I was surprised because I found his beginner's guide on C++ quite easy to read and understand. (And...
Making a blackjack game with Java, but it won't compile :cry:. Can't figure out why.
Code
import java.util.*;
class Blackjack
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
Deck myDeck = new Deck();
Player me = new Player(1000)...
Hi guys, I'm being asked to do a mini-project...Basically, i get a code in JAVA and "edit". Editting can be improving the interface, adding exception handling or adding features and so...I chose Sudodu as my topic..after much searching I found this code but I'm out of ideas, what can be improved...
Could someone check the following 3 classes for me please?
public class LinkedList<T>
{
public Node<T> first;
public Node<T> last;
protected class Node<T>
{
public Node<T> next;
public Node<T> last;
}
public class Iterator<T>
{
protected...
Hi I'm struggling to create a DoublyLinkedList<T> class in Java.
Well,it's actually the iterator that's freaking me out..
Most tutorials and documents I've read use three classes for this:Node<T>,DoublyLinkedList<T> and LinkedListIterator<T>.
I can see the point in creating Node and...
My problem is the first one listed here http://java.sun.com/docs/books/tutorial/getStarted/problems/index.html
But when I type C:\jdk6\bin\javac HelloWorldApp.java I get the message "The system cannot find the path specified."
Both the compiler and HelloWorldApp.java file are in C:/ folder...
here is my code
import javax.swing.*;
import java.text.*;
import java.awt.event.*;
public class Ch6Bagel extends JFrame implements ActionListener, ItemListener {
//create GUI objects
JPanel mainPanel = new JPanel();
JTextField bagelQuantityTextField = new JTextField(10)...
For object-oriented programming course this semester, I have the last-assignment. The assignment requests the student to build an adventure game. The game, of course, have to apply GUI components. We are allowed (and encouraged) to continue last-year course-participants project. I have decided...
I'm creating an application that allows the user to choose one variety of bagel and the quantity of bagels he wishes to purchase. The user can choose if he wishes to buy cream cheese and choose the variety he wishes to add to his purchase. My calculation isn't working correctly.
Here is...
I'm supposed to calculate the cost of renting a Ford, Cadillac or Toyota, and use conditional statements to calculate the different costs of each vehicle.
users are supposed to enter “F” for Ford, “T” for Toyota, or “C” for Cadillac
users enter “F” for Ford, “T” for Toyota, or “C” for Cadillac...
This is really making me mad. I keep getting a "this method must return a result of type int" error message, but obviously I have a return statement trying to return an int. This is a program that is supposed to perform a sequential search for a string index.
public static int...
I'm trying to create a bookstore calculation program with two classes, a presentation and computation class. Here is my code for the presentation class:
import javax.swing.*;
import java.awt.event.*;
import java.text.*;
import java.awt.*;
public class ch4Book extends JFrame implements...
[SOLVED] Simple Java Problem
Hello,
In my computer science class, we were assigned to design an annagrams class, which would create a HashMap of String => HashSet, a sorted sequence of letters mapped to all annagrams of those letters found in the dictionary. This was done.
Sample entries...
i am trying to display the output in a jlabel. I have created individual jlabels for the package ID, weight, and shipping cost and tried to display them with the mainPanel:
import javax.swing.*;
import java.awt.event.*;
public class shippingCharge extends JFrame implements ActionListener
{...
Hello!
I have a project in which I must simulate a blog application,with users' post mangament.
These are the requirements:
A blog has a title and a collection of posts.The posts have the following information:
-author
-data
-title
-text
Each post has a code that is generated...
i'm supposed to create a GUI project that will display a package ID and calculate its shipping cost. the shipping cost is calculated per ounce, and i must convert the pounds to ounces for the shipping cost. everything seems to be working fine except for the calculation. the shipping cost is...
I had to write a java program that will give you the change for whatever random number that program picks. I keep having a problem with the pennies. If have to have more than one penny then program will repeat the output until it gets the pennines right. PLEASE HELP! I am not really good at...
Hello. I am having some trouble getting a java program to work. I am supposed to make a program that takes a word and a file name, and finds all lines in that file that contain that word.
The word that I chose was "try", and the file was "Sgrep.java"
Here is the main method:
class main...
[SOLVED] Java LinkedListNode class
Hi..
I'm trying to understand a generic linked list...in Java.
I understand that I should have a LinkedList class containing a Node class.
The Node class should have an info variable and a link variable.These variables should be accesessed through the...
So I have to create a UML diagram for my program:
import java.util.*;
import java.text.*;
public class NameDate {
public static void main(String[] args) {
// Input the first, middle, and last name
// Display the name and the date.
String firstNameString, middleNameString...
Supposed to make a program that displays an entered name and date, etc, but it won't run.
import java.util.*;
import java.text.*;
import javax.swing.*;
public class ch2NameAndDate {
public static void main(String[] args) {
// Input the first, middle, and last name
//...
Hi, I've recently written a small program to calculate multiplicative group tables for Z mod n. I wrote it in java, as that's the only programming language I currently know.
import java.util.*;
public class ZnX
{
public static int gcd(int a, int b)
{...
Here's a java applet that shows the electric field of a moving charge (it's actually incorrect, it only gives a rough idea how motion and acceleration affect electric field).
http://www.cco.caltech.edu/~phys1/java/phys1/MovingCharge/MovingCharge.html
Can a java applet like this be the same...
Hey guys, I am learning Java and am attempting a project from a book, but I have run into a problem. I don't have an issue when it comes to harvesting an address that has whitespace on both sides. My issues come when a) the input doesn't contain whitespace on either side of an address and b) the...
Which one is better?
It turns out that AJAX suffers from the fact that 90% of development time is spent trying to work around intricacies of specific platforms, which is why google came up with a library that converts JAVA applets into AJAX code.
But why not stick with JAVA anyway? Can't JAVA...
I just have a question about my "solution" to a problem. The question says to write a value returning method that returns the number of rows in a two-dimensional array of doubles.
It should be simple enough and so I did it like this:
public int countRows()
{
int x;
x = 0;
for (int...
OK here is my source code for a small Java program I wrote to approximate the number e:
import java.util.Scanner;
public class E
{
public static void main (String[] args)
{
double e = 0.00, current_e = 0.00;
int x, number_of_digits;
Scanner scan = new Scanner (System.in)...