211 Posted Topics

Member Avatar for churva_churva

The difinition of the two methods from the line 15 to line 20 has some problem. The line 16 should be: return count== EmpYee.length; The line 19 should be: return count==0;

Member Avatar for javaAddict
0
423
Member Avatar for nix_xin

nix nix, it is seen from the output shown in your post that [CODE]* * ** ** *** *** **** **** **********[/CODE]at the 1 st row: 1 star, 8 spaces, and 1 star are printed at the 2 nd row: 2 stars, 6 spaces, and 2 stars are printed at …

Member Avatar for Xufyan
0
175
Member Avatar for pennylynne

(1) In the constructor you have redundant declaration for these attributes private JRadioButton courier, timesnr, helvetica; which makes them become the local variables within the constructor, but the actual three attibutes are still null. (2) The radioButtons have to be grouped so that the client may select only one of …

Member Avatar for pennylynne
0
115
Member Avatar for emko

(1) write a static method where the essential code has been already made as you posted: [CODE]static char letterToInt(char c) { switch (c) { case 'A': case 'a': case 'B': case 'b': case 'C': case 'c': return '2'; /* no "break" is needed becasue we have had the "return" */ …

Member Avatar for emko
0
4K
Member Avatar for Xufyan

The index of the 10th position is 9. When (tos==9), that is the highest index is 9, the StackArray is full, which means the last value has been already stored in the 10th position. If you want to have no value stored at the 10th position, the condition has to …

Member Avatar for NormR1
0
284
Member Avatar for NewOrder

[QUOTE] what does this fucntion do. why do i need it if it is empty[/QUOTE] You may insert some code into the method void print(){...}. If there is no such a method, the line 23 @Override should be deleted. [QUOTE]why do i need to use inheritance here?[/QUOTE]In the class InnerEx7 …

Member Avatar for NewOrder
0
115
Member Avatar for lockwater

[QUOTE]the conversion [/QUOTE] Use the static method of class String: String valueOf(int i )/String valueOf(double d)/String valueOf(float f) in java.lang to convert number to words

Member Avatar for tong1
0
126
Member Avatar for mitchneys

see: [URL="http://www.roseindia.net/java/example/java/swing/DisplayImage.shtml"]Display Image in Java[/URL]

Member Avatar for tong1
-1
85
Member Avatar for raym.mart

For example, to get the factorial of n where n is in int. The result is the final value of fac. [CODE]long fac=1; int i=1; while ( i<=n ) { // the condition for execution of the loop fac *= i; // the previous factorial (factorial of i-1)is multiplied by …

Member Avatar for vaibhav1983
0
78
Member Avatar for flyingcurry

I have questions for you. (1) Where is the definition of the class Console? As fas as I know it is a defined class in the package: java.io (2) For line 15: in the class Graphics there is a member method drawRect(int x, int y, int width, int length), but …

Member Avatar for tong1
0
214
Member Avatar for samuel17

The following errors should be corrected. The code line 19 should be: years = Integer.parseInt(yearsInvest); The code line 20 should be: while(yearsloop < years) The code line 22 should be: balance = investment * Math.pow(1.0 +rate/100, yearsloop); The code line 23 should be: JOptionPane.showConfirmDialog(null, The code line 27 should be: …

Member Avatar for tong1
0
240
Member Avatar for terzenta

If both files under the same folder, (1)remove line 3 in the file Main.java, i.e. remove "package deposit_withdraw;" (2) in lines 31 and 34 in Main.java, the method getBalance should be written as myAccount.getBalance();

Member Avatar for terzenta
0
150
Member Avatar for samuel17

(1)You have to assign the following variables an initial value, such as 0 for init or 0.0 for double in lines 10,11, and 12: double withholding= 0.0; double netPay= 0.0; int withholding1= 0; to pass the compiling. (2) You have to delete the pair of curly brackets at the line …

Member Avatar for samuel17
0
214
Member Avatar for Wootens

[QUOTE]If the number is divisible by 3 or by 5[/QUOTE] if (number%3==0 || number%5==0) [QUOTE] If the number is divisble by 3 and 5[/QUOTE] if (number%3==0 && number%5==0)

Member Avatar for Wootens
0
176
Member Avatar for darkdai

If I understand correctly you want to do some java program for cell phone. You need a J2ME development environment so that you may develop some java application, resulted in a file.jar (an executable jar file) ready for cell phone. Your computer should have JDK 1.6 environment. Then download [URL="http://www.oracle.com/technetwork/java/javame/downloads/sdk30-jsp-139759.html"]the …

Member Avatar for nbaztec
0
152
Member Avatar for javanewb101

You should use a browser or the command: appletviewer in DOS window to open a html file where the applet code, i.e. the file of the applet code is in the same directory/folder, is available: <html><applet code="####.class" width=400 height=500></applet></html> There is nothing to do with main method.

Member Avatar for javanewb101
0
237
Member Avatar for cretaros

Because there is no handle for the member method dispose(), hence there is no idea about which frame is to be disposed. Try: frame.dispose();

Member Avatar for JamesCherrill
0
107
Member Avatar for Jake2025

(1)Create a String object, for instance s (e.g., String s="";) to accommodate the information obtained from your for loop: for(int a=0 ; a<values.length ; a++){ System.out.println("[Firstname Length: "+values[0].length()+" ]" +"[Lastname Length: "+values[1].length()+" ]" +"[Employee IDnumber: "+(i+1)+" ]"+" = "+ staff[i]); a++; } (2)Create a BufferedWriter bw in the following way: …

Member Avatar for Jake2025
0
119
Member Avatar for PDB1982

kvass's way is feasible. Check the input digits' string to see if its length is 5 nor not. If not then ask client to re-enter a 5 digits' number. There is no way to restrict number of characters a user types in at the console during typing.

Member Avatar for tong1
0
110
Member Avatar for lilsmurf

For the variable date should we define as String? [CODE]String date = "01/01/2010"; // To hold the date[/CODE] The code in line 33 would be: [CODE]date = keyboard.nextLine(); // To receive the date as a String[/CODE]

Member Avatar for NormR1
0
749
Member Avatar for sheiyvin
Re: java

If the digit number is understood as int data, then class String has static String valueOf(int i) method which converts the int data into String.

Member Avatar for Akill10
0
55
Member Avatar for jwmollman

jwmollman, Can you modify your code by the following 2 changes? (1) in line 34, replace intTriangleHeight with intIndex1 so that the line of code will be: [CODE] for (int intIndex2 = 0; intIndex2 <= intIndex1 ; intIndex2 += 1) // control the number of symbles for each row[/CODE] (2) …

Member Avatar for tong1
0
245
Member Avatar for cirvelasares

Please study [URL="http://www.dgp.toronto.edu/~mjmcguff/learn/java/"]Java Applet Tutorial http://www.dgp.toronto.edu/~mjmcguff/learn/java/[/URL]

Member Avatar for coil
0
62
Member Avatar for jackcfj0129
Re: loan

The formula for Monthly Payment is incorrect. It should be: Monthly payment = ((Loan Amount*Monthly Interest)/(1-(1+monthly interest)^(-number of years*12)) The method to calculate the Monthly Payment should thus be: [CODE]public static double monthlyPayment (double aI, double loanAmt,int years ){ double mp; double mi = aI/1200; mp = loanAmt * mi …

Member Avatar for tong1
0
1K
Member Avatar for acash229

int line 62, the denominator should be 1000.0: elapsedTimesec1 =(double)(elapsedTimeSec - start)/1000.0; also see: [URL="http://www.daniweb.com/forums/thread310983.html"]http://www.daniweb.com/forums/thread310983.html[/URL]

Member Avatar for brandonrunyon
0
292
Member Avatar for extemer

The following code could be helpful. [CODE]public class Prinf{ static double decimal(double d){ int dd = (int)d; d -=dd; return d; } public static void main(String args[]){ double d = 6.328941; System.out.printf("%8.6f\n",decimal(d)); } }[/CODE] output: 0.328941

Member Avatar for extemer
0
12K
Member Avatar for rayden150
Member Avatar for acash229

I have modified your code between line 41 and 62 as follows: [CODE] if (source == theMainButton) { resizeComponent(this); setLocation(rand.nextInt(screenSize.width-3*BUTTON_WIDTH), rand.nextInt(screenSize.height-3*BUTTON_HEIGHT)); long start = System.currentTimeMillis(); // get the starting milli-seconds n++; if(n>=8){ JOptionPane.showMessageDialog(null, "You Clicked it " +n); long elapsedTimeSec = System.currentTimeMillis(); // get the stoping milli-seconds, elapsedTimesec1 =(double)(elapsedTimeSec - …

Member Avatar for acash229
0
308
Member Avatar for nix_xin

in lines 7,10, 13, the methods nextInt(), nextFloat() are called. the () is missing. The code should be: double inInt = nix.nextFloat(); ... int inYear = nix.nextInt(); ... int inLoan = nix.nextInt(); You are using the static method of pow of the Math class. If your fomula is correct, the …

Member Avatar for NormR1
0
179
Member Avatar for Jiblix

The errors I have found are indicated as follows: (1) line 10 is a header declaration (import java.util.*;", which should be place in "the heading part", i.e. the first line of the code. (2) line 13: The class name is Scanner rather than scanner; (3) lines 25,27: the method println(...) …

Member Avatar for Jiblix
0
232
Member Avatar for blknmld69

You did not difine the following classes: gradeTypePabel,namePanelname, testPanel panel , and resultPanel

Member Avatar for NormR1
0
263
Member Avatar for TheWhite

Call stop() method to kiill the thread. [CODE]import java.lang.Runnable; public class T implements Runnable{ Thread timer = null; public void start() { if(timer == null) { timer = new Thread(this); timer.start(); } } public void stop() { timer = null; } public void run( ) { while (timer != null) …

Member Avatar for ~s.o.s~
0
155
Member Avatar for gudads

[URL="http://www.concentric.net/~Ttwang/tech/javafloat.htm"]Java Floating-Point Number Intricacies[/URL][url]http://www.concentric.net/~Ttwang/tech/javafloat.htm[/url]

Member Avatar for gudads
0
485
Member Avatar for gudads

the printf(...) ,which is a C-style output, is used starting from JDK1.5. for the details about java printf() see [URL="http://www.java2s.com/Tutorial/Java/0120__Development/UsingJavasprintfMethod.htm"]6. 14. 1. Using Java's printf( ) Method[/URL]

Member Avatar for gudads
0
861
Member Avatar for Sunshineserene

The methods of an [URL="http://en.wikipedia.org/wiki/Inner_class"]inner/nested class [/URL] may also directly access the variables of its top-level class. So in some case one may declare a class entirely within the body of another class

Member Avatar for tong1
0
14K
Member Avatar for extemer

The area of a circle is 3.14*radius*radius rather than 3.14 *(radius*2) The following static method start() may do one run to calculate the area of a circle. [CODE]private static void start() { String n = JOptionPane.showInputDialog(null,"Enter the radius to calculate the area of a Circle"); int num = Integer.parseInt(n); DecimalFormat …

Member Avatar for coil
0
103
Member Avatar for shivaniaroraji

Instance variable/method - Variables/methods that are specific to each instance (object) of the class e.g. name, age.... When accessing/calling them, the object, as the reference has to be used as a handle. Class variable/method - Variables/methods that represent/deal with class wide situation, e.g. a static variable which belongs to a …

Member Avatar for shivaniaroraji
0
210
Member Avatar for LianaN

I wrote a testing program as follows. If I clicked twice the label is deleted. Perhaps for the line 5: [U][B]this.layeredPane.remove(e.getComponent());[/B][/U] your may replace e.getComponent() with actual reference: "label". [CODE]import java.awt.*; import java.awt.event.*; import javax.swing.*; public class DeleteComponent extends JFrame { JLabel label; public DeleteComponent(){ Container container = getContentPane(); label …

Member Avatar for LianaN
0
204
Member Avatar for kch1973

kch1973 , the following comments for your consideration. 1. Since the reference of the array is in fact passed to the sortArray method (i.e. pass by reference), no return value(s) is needed. Therefore the definition of the sorting method would be: public static void sortArray ([B]Printer[] a[/B]){...} where The argument …

Member Avatar for tong1
0
76
Member Avatar for NewOrder
Member Avatar for gudads

Your code is basically correct. Please use the tag [CODE] for your code. I have made a small modification. I am not sure if there is a term called "accumulated interests" which is different from simple interests. import java.lang.*; public class simple { public static void main (String[] args){ // …

Member Avatar for gudads
0
184
Member Avatar for Xufyan

[CODE]import java.io.*; class vowel{ public static void main (String args[])throws IOException{ String sentence; InputStreamReader isr = new InputStreamReader (System.in); BufferedReader br = new BufferedReader (isr); sentence = br.readLine(); System.out.println (vowels(sentence)[0]); System.out.println (vowels(sentence)[1]); } static Object[] vowels (String default1){ // return an Object array including various data types char ch; int …

Member Avatar for Xufyan
0
205
Member Avatar for fr0styh3rb

line 24,25,26: You have incoorectly made 5 parameters for the constructor, but in fact the Camera constructor requests 4 arguments: Camera( String Name, int Number, int Units, double price ) // see line 120 ... According line 30,31: Camera.showInventory(); The showInventory() method must be a static since you use the …

Member Avatar for tong1
0
151
Member Avatar for boiishuvo

I have modified your code by adding the paint() method to draw string, oval, and rectangle, from which you may start to taste the Graphics methods. Read the API to find more methods of Graphics. [CODE]import java.awt.*; import javax.swing.*; public class DrawGraphics extends JFrame { private JLabel label1; private JLabel …

Member Avatar for tong1
0
151
Member Avatar for Premsathishbe

for (double d : numbers) { total += d; } is equivalent to: [CODE]for (int i=0; i<numbers.length;i++){ double d = numbers[i]; total += d; }[/CODE]

Member Avatar for tong1
0
96
Member Avatar for nur_ahm4d
Member Avatar for jon.kiparsky
0
242
Member Avatar for BboyRodimus

The line 3 and 4: private string city; private string state; The type of both attributes city and state should be [B]S[/B]tring

Member Avatar for NormR1
0
279
Member Avatar for rayden150

First you may try the class : javax.swing.JOptionPane You should at first [CODE]import javax.swing.JOptionPane;[/CODE] Then you may, for example, replace line 14 and 15 by the following code: [CODE]String input = JOptionPane.showInputDialog("To Order new item. Press Y to leave press any other key..");[/CODE] Try it. Does it work? Read API …

Member Avatar for tong1
0
191
Member Avatar for BboyRodimus

I guess, in the Bank's constructor, the attribute "bankAddress" should be: bankAddress = new Address(); Where is the code for the definition of Bank class?

Member Avatar for sneaker
0
1K
Member Avatar for bibiki

When executing the line of code: System.out.println(new Final(2)); an address of the instance of the Final is printed as 9cab16 (Final@9cab16) which tells that the instance of Final is stored at the memory: 9cab16 in hexadecimal system

Member Avatar for JamesCherrill
0
77

The End.