Forum

Posts

RECENTLY INDEXED PROGRAMMING SOLUTIONS OF Java


Help me understand how this polymorphism example works  

Java Code: public class PolymorphismDemo { /** Main method */ public static void main(String[] args) { // Display circle and rectangle properties displayObject(new Circle4(1, "red", false)); ... Continue Reading
Views : 42
Monday 24th of September 2012

What is the instance name of GCanvas automatically created in GraphicsProgram  

Hi, If I create a instance of GraphicsProgram class like: public class graph extends GraphicsProgram{....} GraphicsProgram will create a instance of GCanvas class automatically which fills the entire program window, so what is the name of this instance name?... Continue Reading
Views : 59
Monday 24th of September 2012

invalid method declaration  

hello everyone, I am newbie at java programming. I am trying to run this code, class Puppy{ int puppyAge; public Puppy(String name){ // This constructor has one parameter, name. System.out.println("Passed Name... Continue Reading
Views : 42
Monday 24th of September 2012

get accountNumber problem  

I have five classes: Account (abstract), SavingAccount, CreditAccount, GUI and Logic. My problem is the showSelecteAccountNumber method, and the problem is in this line: if(selectedAccountNr==konto.getAccountNumber()){ selectedAccountNr is no problem. It comes from the... Continue Reading
Views : 74
Monday 24th of September 2012

Help with making a windows like calculator!  

this is working but I have some problems. This should supposed to work like the windows calculator say, I input "2+3*4/3" (without using the equals sign)...It will not give me the correct result.Another problem is that, for example you type "2 +" then you decided to use "-"... Continue Reading
Views : 70
Monday 24th of September 2012

InputMismatchException  

Working my way thru a basic java programing book I came across a strange problem . Trying to get keyboard input through scanner I get a InputMismatchException when I enter 2dot5 ( 2.5 ) but it takes it as a double when I enter 2comma5 (2,5). Anybody know what could be happening? ,... Continue Reading
Views : 58
Monday 24th of September 2012

Call class libabry classes from a separate java application project  

Hi I have 2 separate projects, the class library project & java application project.I have a class in my class library called "myclass" and has a method called "search()" I need to refrance the class library project so i can use its classes in my java application... Continue Reading
Views : 62
Monday 24th of September 2012

Java upload applet, communication with server  

Hi fellow Java coders I have the source code for a java applet used on a website for uploading files. I have thoroughly been searching the code for the part where it send the messages to the server. Where can I find this in the source code, it is not in the config folder as I had... Continue Reading
Views : 49
Monday 24th of September 2012

Need help with this assignment  

Hi guys! First post and I need help with 2 problems in an assignment, or at least a hint on how to do them if homework help isn't allowed :p First problem Java Code: Continue Reading
Views : 70
Monday 24th of September 2012

Input String to boolean equation  

I was trying to figure out how to work with CASE_INSENSITIVE, but that failed. So I decided to break it down and simply write an if for "n" and "N". PROBLEM:The code compiles fine as is. But all I ever get is the "Liar".I don't seem to understand why if(ready == "N" ...... Continue Reading
Views : 49
Monday 24th of September 2012

Calendar operation  

I have a date - example - 22-09-2012(start date) I have to find my end date based on the current quarter My input are month of the quarter which is a list box with values(1,2,3) , Day of the month in list box with values ( 1 to 31) If my current quarter is 1 (Jan to Mar)... Continue Reading
Views : 45
Monday 24th of September 2012

Conversion of any image file to text file in Java...'  

The following code reads the image file and store its Pixel values(ARGB) in text file....' A - Alpha' R - Red' G - Green' B - Blue'' Continue Reading
Views : 41
Monday 24th of September 2012

Splitting an string of number into multiple lines using isLetter()  

Here is the code Java Code: /* * Read in one line of text, and then break up the words. * example * * input: * this is a line * * output: * this * is * a * line */public class... Continue Reading
Views : 71
Monday 24th of September 2012

for loop help  

I am given this objective Lab Description : Run a loop from a provided start number to a provided stop number. Total up all numbers in the group,... Continue Reading
Views : 53
Monday 24th of September 2012

ClassCastException in Custom class loader  

1.I have created a custom class loder. ClassLoaderDemo ccl = new ClassLoaderDemo(); //assume it is working fineClass clas = ccl.loadClass( "com.MyObject" ); com.MyObjectSuperClass o1 = (com.MyObjectSuperClass)clas.newInstance(); //MyObjectSuperClass is... Continue Reading
Views : 84
Monday 24th of September 2012

What is wrong with my program  

import javax.swing.*;import java.util.*;import java.text.*; class Box { //Data Members private static final double BAGPRICE= 5.50; private static final double LRGPRICE= 1.80; private static final double MEDPRICE= 1.00; private static... Continue Reading
Views : 60
Monday 24th of September 2012

How can i make mutiple house appear on my screen and populate it off this program  

I need to supply a house constructor for specifying the position and sizei'm new to programming so i don't really understand java as much import java.awt.Graphics;import java.awt.Graphics2D;import java.awt.Color;import java.awt.geom.Line2D;import... Continue Reading
Views : 75
Monday 24th of September 2012

Validation  

Hi all, im trying to do a little validation here. I have a switch statement that takes in a int from the user but I want to not allow any characters. I did the try catch and it did work but then my program just ends. Any thoughts? Continue Reading
Views : 45
Monday 24th of September 2012

Calling a private method with an exception in a constructor  

Hello I am having trouble calling a private method in my constructor. I have a private method called "dostuff()" that has an exception. I then called the method in my constructor "this.dostuff()" and I got and error saying "unreported exception java.lang.Exception; must be caught or declared... Continue Reading
Views : 58
Monday 24th of September 2012

Comparing Sorting algorithms  

Hi, My assignment is to write a program which compares sorting algorithms (bubble, selection, insertion) with the respect to number of exchanges and comparisons. Each algorithms sorts three lists of 2000 integers, one already sorted, one in revers order and on with random order. Can... Continue Reading
Views : 48
Monday 24th of September 2012

How do I make classes  

The compnay sells coffee bags for $5.50 each. When someone makes an order it gets shipped in boxes. Large- Holds 20, $1.80 a box.Medium- Holds 10, $1.00Small-Holds 5, $0.60 I understand how to make constants but not the rest I need help. Prints like: Continue Reading
Views : 68
Monday 24th of September 2012

Help with Delimiters/While loops  

* This is project 17 and it asks to create a code that uses delimiters/while loops to add or subtract numbers, but I have no idea how to code that! I used the s.contains("-") and s.contains("+") in two if statements with while loops in them, but it wouldn't work. Please tell me the best way to... Continue Reading
Views : 98
Monday 24th of September 2012

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException  

I've looked at my errors, and I am new to java so i research what some of my errors mean. the problem is that i am having a hard time figuring out how to fix the problem. Alot of the other stuff that says unknown source, I have no idea how to fix. Any help or pointers will be... Continue Reading
Views : 49
Monday 24th of September 2012

Question about how Modulus works  

Hi there I just started programing and was practicing by making a program that converts meters into inches, feet, and miles. I finished it up and decided that rather than having feet be in decimal I wanted to make it look better by cutting off the decimal and converting it to inches. Continue Reading
Views : 46
Monday 24th of September 2012

Clueless as to what is wrong.  

I have written some code to "print out three lines for each loan, giving the amount of monthly payments, the interest paid over the life of the loans, and the total amount paid back over the life of the loan, with appropriate wording."I was given a formula to figure out the monthly... Continue Reading
Views : 138
Monday 24th of September 2012

I need help finding a remainder  

Hey guys im writing a program for my computer science class and its kicking my ass. The think im having a problem with is making it tell me what the remainder is im using the modulous *correctly i think* but it keeps being weird. Ill show you the code ive wrote so far import... Continue Reading
Views : 66
Sunday 23rd of September 2012

How is the Value of ~a obtained in the below program  

All the answers come out the same! I might have expected 101010, but not 0011. Look at the code to see why everything is coming out =0011. , BB Code List - Java Programming Forum Continue Reading
Views : 40
Sunday 23rd of September 2012

It keeps trying to get me to close parentheses...  

Ok so this is really hard to explain. Ive already asked a question on here about a hour ago so i hope i dont get hate from mods for posting again so soon (or other peopl) but this one is just weird. ive wrote the code correctly but when i try to ad " " to put a space between the variables i... Continue Reading
Views : 140
Sunday 23rd of September 2012

Creating random numbers  

Hi. I just started programming Java two weeks ago and I am starting to get the basics (I think).But now I have written a program (in Eclipse) and I get errors which I don't understand.Has anybody got an idea of what is wrong with this code? (I want to create some numbersin... Continue Reading
Views : 41
Sunday 23rd of September 2012

What are you using to write your code  

Just thought it'd be cool to get an idea of what the members here are using for editors/IDEs. Vote for your most frequently used editor/IDE and if it's not listed here(10 is the max :(), feel free to check other(but please post about it). Have fun! As requested, this is a growing... Continue Reading
Views : 54
Sunday 23rd of September 2012