Posts
 
Reputation
Joined
Last Seen
Ranked #1K
Strength to Increase Rep
+6
Strength to Decrease Rep
-1
85% Quality Score
Upvotes Received
33
Posts with Upvotes
33
Upvoting Members
17
Downvotes Received
5
Posts with Downvotes
5
Downvoting Members
4
13 Commented Posts
0 Endorsements
Ranked #280
~165.90K People Reached

211 Posted Topics

Member Avatar for student.09

[CODE]public class MyPoint { private int x,y; public MyPoint(){ x=0; y=0; } public MyPoint(int x, int y){ this.x=x; this.y=y; } /* now Two get methods for data fields x and y, respectively. */ ..... }[/CODE]

Member Avatar for sahil_26
0
7K
Member Avatar for prem2

You may declare a method (in java we call function as method) as abstract which means no definition is given, e.g. [CODE]void show();[/CODE] You may declare a method with empty body, which isn't an abstract method anymore. [CODE]void show(){};[/CODE] but do nothing when calling it. Or you may define a …

Member Avatar for JamesCherrill
0
4K
Member Avatar for Techboy52

The JOptionPane's showMessageDialog is indeed shown, but it is covered by the DOS window. After you move the DOS window away you will be able to see the JOpationPane's showMessageDialog. This is my observation.

Member Avatar for stultuske
0
4K
Member Avatar for ezkonekgal

Your code shown above is correct. I have tested with a known file. The result is correct. AS long as the browsing files is concerned, as jon.kiparsky indicated, it is already available in Swing. For example, the class FileDialog is a candidate for this purpose. Since its constructor requests a …

Member Avatar for emoon11
0
2K
Member Avatar for jtresue

Your forgot to add the component userMessageLabel into container: [CODE]add(userMessageLabel); // this line of code is missing[/CODE] Please use CODE tag to post your code so that one may refer your certain code to a specific line number

Member Avatar for JamesCherrill
0
3K
Member Avatar for loozax

StringBuffer has an instance method: reverse() to do the reversing job. [CODE]import java.io.*; import javax.swing.JOptionPane; public class Palindrome{ static boolean palindromeCouplet (String s) { StringBuffer s1 = new StringBuffer(s); return ((s.compareTo(new String(s1.reverse()))==0) ? true :false) ; } public static void main(String[] args) { while(true){ String str=JOptionPane.showInputDialog( null, "Type in a …

Member Avatar for JamesCherrill
0
712
Member Avatar for xterradaniel

Following javaAddict's code, I have replaced the BufferedWriter and FileWriter with BufferedReader and FileReader. In order to get each integer value back, the method of class String split is given the delimiter of a space " ". Please read the method of String split(...) in API. Therefore, for reading the …

Member Avatar for nate.nelson.566
0
3K
Member Avatar for bymak87

Please have a look at the thread: [URL="http://www.daniweb.com/forums/thread299093.html"]array sort of 10 integers in ascending and descending order Bubble sort http://www.daniweb.com/forums/thread299093.html[/URL]

Member Avatar for nate.nelson.566
0
1K
Member Avatar for amit.hak50
Member Avatar for rajesh_tawari

Animation in Java JDBC application Statistics on English words obtained from a text file Some demonstration on data structure

Member Avatar for stultuske
0
363
Member Avatar for toferdagofer

In constructor you redefine the label2,label4,label6, and label8 as local variable of the type JTextField, which is wrong. You have already declared them as attributes. You should thus replace the 8 lines of code in the constructor by the following code: [CODE]JLabel label1 = new JLabel("Enter the price of one …

Member Avatar for DavidKroukamp
0
1K
Member Avatar for Litcandle

[CODE]import java.io.*; import javax.swing.JOptionPane; public class PalindromeCouplet{ static boolean palindromeCouplet (String s) { StringBuffer s1 = new StringBuffer(s); return ((s.compareTo(new String(s1.reverse()))==0) ? true :false) ; } public static void main(String[] args) { while(true){ String str=JOptionPane.showInputDialog( null, "Type in a string!\nPress Cancel to terminate the program", "Palindrome or Not?", JOptionPane.QUESTION_MESSAGE); if …

Member Avatar for stultuske
0
411
Member Avatar for VinC

Thank you, VinC, for sharing the "Covariant". line 22 shows that g is a variable of type Grain. line 25 shows that a variable of type Grain is capable to receive a value of type Wheat. Why? Because Grain is super class of class Wheat. Wheat is a kind of …

Member Avatar for DavidKroukamp
0
158
Member Avatar for perlsu
Member Avatar for mubin_89
1
4K
Member Avatar for AhmedGhazey

It happends with Chinese characters as well. I think this is probably due to the computer system (windows' config) where your output is printed.

Member Avatar for ahmaadaadel
0
4K
Member Avatar for webmasts

A further development of extemer's program leads to the following table showing the furture values of one thousand dolloars investment calculated based on compound interest: a(t) = (1 + i)^t where i is rate while t the number of years [CODE]import java.text.DecimalFormat; import javax.swing.*; import javax.swing.JTextArea.*; class TextAreaDemoB { public …

Member Avatar for Donkerster
-1
1K
Member Avatar for lynnajoe
Member Avatar for desert564

The main method should be written as follows: [CODE]public static void main(String args[])throws IOException { sp obj=new sp(); obj.takenum();obj.showresult(); }[/CODE]

Member Avatar for desert564
0
93
Member Avatar for sach_ak47

If you have already had JDK 1.6 in your machine then download [URL="http://www.oracle.com/technetwork/java/javame/downloads/sdk30-jsp-139759.html"]Java ME SDK 3.0 http://www.oracle.com/technetwork/java/javame/downloads/sdk30-jsp-139759.html[/URL] do some programing in J2ME Then under your working folder : [B]projectName/dist/[/B] you may find the corresponding file ***.jar ready for mobile phone .

Member Avatar for Hakoo
1
944
Member Avatar for jwmollman

(1) The code in the line 12 is not correct. The code in line 12 could be: intTotal = intTotal + intCounter; or intTotal += intCounter; (2) The code in line 13 should be moved/inserted into the place between the line 14 and 15. (3) The initial value for the …

Member Avatar for kikovi
0
183
Member Avatar for flyingcurry

(1) flyingcurry ,if you have to sort the whole array the second argument “length” is redundant. In fact, the length is the array.length。 (2) The line 13 could be replaced with [CODE]for (j=0; j<length-1-i; j++) //to avoid the unnecessary comparisons made of the stable region.[/CODE] See [URL="http://www.daniweb.com/forums/thread299093.html"]the post on bubble …

Member Avatar for apines
0
177
Member Avatar for spades0001

One should write the following line of code to update the control variable ctr (the ODD numbers less than 10): [CODE]for (;ctr<=10; ctr+=2, ctr2++) {[/CODE]

Member Avatar for tong1
0
130
Member Avatar for ceyesuma

Just for your [URL="http://docs.python.org/tutorial/datastructures.html"]reference.[/URL] In Pyphon the list data type has a method: pop(). list.pop([i]) removes the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in …

Member Avatar for ceyesuma
0
319
Member Avatar for frankel81

The difference between two adjacent numbers in the series of numbers increases one each time. Therefore, one has to update the difference by one increment each time: [CODE]difference++[/CODE] Hence one may calculate the next number by the following code: [CODE]num +=difference++;[/CODE] Therefore the for each loop could be written as …

Member Avatar for Eric Cute
0
150
Member Avatar for ssubnel

(1) You may define the method as the main(). Hence replace the line 8 with [CODE]public static void main(String args[] ){[/CODE] (2) You forgot to create the instance of Scanner: input. Hence insert line 8 the following code: [CODE]Scanner input=new Scanner(System.in);[/CODE]

Member Avatar for ssubnel
0
95
Member Avatar for mbouster

The UML for the class MyPoint could be written as follows: -x : double -y : double +MyPoint() +MyPoint(x:double,y:double) +getX() : double +getY() : double +setX(x:double):void +setY(y:double):void +distance(AnotherPoint:MyPoint):double +distance(p1:MyPoint,p2:MyPoint):double

Member Avatar for tong1
0
609
Member Avatar for Lxyslckr

Note that the instructor asks to verify the value provided for "year" is at least 1908 and at most 2012, hence the code should be: [CODE]if (y >= 1980 && y<= 2012) year=y; else year=2010;[/CODE] The following code by using ternary operator is also valid: [CODE]year = ( y>=1980 && …

Member Avatar for Lxyslckr
0
103
Member Avatar for riahc3

The class Math in the package java.lang has a static method random() which returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. I use this method to generate random number. For example, to generate a integer varying from 0 to 255 …

Member Avatar for tong1
0
155
Member Avatar for vishalonne

In the definition of class EnemyShip, you may add a static int attribute numEnemieShip from which you may know the number of enemy ships created from time to time. Hence, the constructor is defined as follows: [CODE]public EnemyShip(int x, int direction){ this.x = x; this.direction = direction; numEnemieShip++; }[/CODE]

Member Avatar for JamesCherrill
0
174
Member Avatar for muraj

In this case you should cast the result of the evaluation of "xCenter + 200 * Math.cos(2 * Math.PI * 3 / 7)" or "yCenter + 200 * Math.sin(2 * Math.PI * 3 / 7)": [CODE]g.drawLine ((int)(xCenter + 200 * Math.cos(2 * Math.PI * 3 / 7)),(int)(yCenter + 200 * …

Member Avatar for muraj
0
108
Member Avatar for hatux

The following code demonstrates how to analyze a keyboard input in terms of tokens. The client may input no more than 100 words with the final string “end” (excluded). These words are simultaneously stored in the String array s, through which one may do search for a specific word. [CODE]import …

Member Avatar for kramerd
0
153
Member Avatar for arawani

Your set methods (settotalPrice() and settotalPriceWithTax()) should be of the type void

Member Avatar for arawani
0
97
Member Avatar for Dean_Grobler

As far as I know, if the instance of JFrame is a, the code for registering its closing button could be one line of code as follows: [CODE]a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);[/CODE]

Member Avatar for masijade
0
130
Member Avatar for Javano

To drawing a line one has to use the instance of Graphics : Graphics g so that the method in drawing a line can be applied: g.drawLine(int x1, int y1, int x2, int y2) ; which draws a line, using the current color, between the points (x1, y1) and (x2, …

Member Avatar for tong1
0
109
Member Avatar for printmatic

Alternatively, one may use the CANCEL button on the input dialog box: JOptionPane.showInputDialog(inputMessage); to check if the program should terminate or not. [CODE]inputString = JOptionPane.showInputDialog(inputMessage); if (inputString== null){ JOptionPane.showMessageDialog(null, "See you next time", "Telephone Digit",JOptionPane.PLAIN_MESSAGE); break; }[/CODE]

Member Avatar for kramerd
0
271
Member Avatar for sciprog1

Any primitive data type has its own wrapper class. The wrapper class of int is Integer which is defined in the package java.lang. Its static attribute MAX_VALUE represents the positive largest value (2147483647)while MIN_VALUE the negative smallest value. In the same way one may obtain the maximum/minimum values for other …

Member Avatar for Dupron
0
153
Member Avatar for bookworm619

As indicated by API : acos public static double acos(double a)Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi. The return value of Math.acos is in radian instead of degree. It has to be multiplied by 57.296 (180/PI) to become the value …

Member Avatar for tong1
0
158
Member Avatar for Xufyan

Xufyan, you may have two control indexes, such as int tosInt=-1,tosFloat=-1 to manage these two indipendent arrays of different data type which store different data. It is a common sense.

Member Avatar for Xufyan
0
1K
Member Avatar for Xufyan
Member Avatar for Xufyan
0
108
Member Avatar for Sunshineserene

Following Dean_Grobler's suggestion you may read each number as a string s, and then convert s into a decimal number in the type of double by the following line of code: [CODE]double d = Double.parseDouble(s);[/CODE] or convert s into a decimal number in the type of float: [CODE]float f = …

Member Avatar for tong1
0
2K
Member Avatar for badae

If multiple choices( selecting one more items at one time) are allowed you may use "if" but no "else". For the 3 choices you may simply use Class JCheckBox. In your layout the selections seem to be more complex than a ckeckbox.

Member Avatar for badae
0
74
Member Avatar for vincent0625

It's impossible to add an integer value into a boolean type array which stores boolean value only.

Member Avatar for NormR1
0
61
Member Avatar for bhanu1607

You may try the following changes. Because we want the smileFlow() runs for a certain time (befor x reaches 600), you have to (1) delete the line code s.smileFlow(); (2) insert the above code s.smileFlow(); after the f.setDefaultCloseOperation(3); so that it runs after setting up the frame properly. P.S. the …

Member Avatar for bhanu1607
0
100
Member Avatar for PDB1982

The index variable "cnt" in line 29 and 35 is 5 after the method EnterNumbers() has been called. The value 5 of the "cnt" is "OutOfBounds". You have to rewrite the method NumberCheck() because it is not functional.

Member Avatar for PDB1982
0
91
Member Avatar for judgemental

(1) The default layout manager for JFrame is BorderLayout where 5 blocks are defined as NORTH,WEST,SOUTH,NORTH,CENTER. So the code: f.setLayout(new BorderLayout()); is redundant. (2) Since the f container is controlled by a BorderLayout when you add any sub-containers into f you have to indicate which block each container goes to. …

Member Avatar for tong1
0
100
Member Avatar for sciprog1

The width of each button is given too small. Try to replace lines 19 and 20 with the following width of 150: b1.setBounds(50, 50, [COLOR="Red"]150[/COLOR], 50); b2.setBounds(50, 125, [COLOR="red"]150[/COLOR], 50);

Member Avatar for sciprog1
0
2K
Member Avatar for coco24

Please fill the following table on a page to trace the nested for each loop: [CODE]for(int count = 0; count <= 3; count++) for(int count2 = 0; count2 < count; count2++) System,out,println(count2)[/CODE] Only when both contitions: (count2<count) and (count<=3) are true, the output is available. If so fill the output …

Member Avatar for tong1
0
100
Member Avatar for allang

Please to use the code tag so that the number of line could be mentioned. I guess that your problem is the control index "currentImage", the global variable, that is out of the bound after completing the first run of the paint(), i.e. after the 15 (totalImages) pictures are displayed. …

Member Avatar for tong1
0
84
Member Avatar for pgset

Please use code tags around posted code to make it more readable. Since your class projectThree extends Applet an method public void init(){...} would be defined instead of a constructor. Hence the code line: public projectThree() should be replaced by public void init() I have a question for your reference: …

Member Avatar for tong1
0
132
Member Avatar for PDB1982

In addition to the way ,as kvass points out, to solve this problem one may write a method to do the checking job: [CODE]/* The method duplicate checks the partial part (the index from 0 up to the n-1) of the array a to see if there is an b …

Member Avatar for kvass
0
92

The End.