1,963 Posted Topics

Member Avatar for mrjoli021

Doesn't this answer your question? [URL="http://www.daniweb.com/forums/thread156720.html"]http://www.daniweb.com/forums/thread156720.html[/URL]

Member Avatar for Ezzaral
-1
143
Member Avatar for enuff4life

Also this is wrong: [CODE] WrongMenu(int n){ System.out.println("you've entered : "+ n); System.out.println("please reenter: "); } [/CODE] The Exceptions don't get created to print messages. With the above the message will be printed when you do: [ICODE]throw new WringMenu(1);[/ICODE] Exceptions need to be caught and handled. Like this: [CODE] catch(WrongMenu …

Member Avatar for Drosty
0
4K
Member Avatar for enuff4life

[QUOTE=Chaster;733579][CODE] String s = new String(""); String s1 = new String(""); System.out.println("enter String : "); Scanner keyboard = new Scanner(System.in); while(!s.equals("end")){ s = keyboard.next(); s1 += s+" "; // or s1 += s+"/n"; } System.out.println("you've typed: \n"); System.out.println(s1);[/CODE][/QUOTE] That is not what [I]enuff4life[/I] has asked. Try this: [CODE] String s …

Member Avatar for stultuske
0
314
Member Avatar for jayjaysam0441
Member Avatar for countrygirl1970

percentage is an array and you do: percentage = frequency * 60000; Also I think you have a problem with your brackets (}) [CODE] public class Assignment5 extends JApplet { .... .... // Multiply the frequency to 60000 to get the percentage line 38 percentage = frequency * 60000; public …

Member Avatar for countrygirl1970
0
119
Member Avatar for c++ prog

Here are some compiler errors: [ICODE]Sanner input = new Scanner(System.in)[/ICODE] [COLOR="Red"]should be[/COLOR] [ICODE]Scanner input = new Scanner(System.in)[/ICODE] Also the <h> variable is never initialized so you will get an error. Try doing h = 0, but then the result would be zero, since you never read it. Also it is …

Member Avatar for VernonDozier
0
146
Member Avatar for AceAtch

[QUOTE=destin;729906]You mean public variable.[/QUOTE] No, [I]stultuske[/I] means: public [B]method[/B]. If it was public variable it should be declared: [ICODE]public double radius = 0;[/ICODE] Instead it is: getRadius. So when AceAtch writes: [ICODE]myCircle.getRadius[/ICODE], probably has something like this: [CODE] private double radius = 0; public double getRadius() { return radius; } …

Member Avatar for javaAddict
0
180
Member Avatar for philmetz

I don't understand exactly what your method tries to accomplish but I believe that initializing sum with counter will get you some results, or/and returning the sum instead of zero at the else {...} : [CODE] public static int myMethod(int counter) { //int sum = 0; int sum = counter; …

Member Avatar for destin
0
96
Member Avatar for pace59
Member Avatar for smakos

I still don't get the poll. What does it mean if I vote the first and what does it mean if I vote the second?

Member Avatar for bobocqu
0
112
Member Avatar for adetya

[QUOTE=adetya;726714]hi! can anyone please help me complete this code[/QUOTE] You have got to be kiding

Member Avatar for masijade
0
178
Member Avatar for janamrob

First of all the way you create your own exceptions is wrong. You don't need to create a String variables: exception. The Exception class has a method: getMessage() which returns the description of the exception that occurred with everything you need to know. So you don't need the getException() method. …

Member Avatar for javaAddict
0
175
Member Avatar for vladdy191

[CODE] public static void main(String [] args) { } [/CODE] The (String [] args) is the argument of the main. When you call the java program with arguments at the command line those arguments are stored in the args array: >java Translate arg1 arg2 "arg 3" Now in your program …

Member Avatar for javaAddict
0
85
Member Avatar for rainny

When you click the button you need to hide the current JFrame and call the other. [CODE] class JFrame_A extends JFrame { .... .... public void methodBuitonClicked( ...... ) { JFrame_B frameB = new JFrame_B(); this.setVisisble(false); frameB.setVisisble(true); } ..... ..... } [/CODE] If you want from the frameB to go …

Member Avatar for javaAddict
0
97
Member Avatar for IMtheBESTatJAVA

You need to put commands such as this in methods: [icode]System.out.println("Input temperature in ºF ---> ");[/icode] Also in java if you want the power of a number use: [icode]Math.pow(double a, double b)[/icode]

Member Avatar for IMtheBESTatJAVA
0
517
Member Avatar for joshmo

You cannot because q is defined in C not in B You cannot because it is declared private. [CODE] class A{ private int o,p; protected B bClass; protected C cClass; public void method() { System.out.println(cClass.o+";"+cClass.p); //this is wrong: bClass.q } } [/CODE] Also none of the above will work because …

Member Avatar for BestJewSinceJC
0
105
Member Avatar for FSinister

Write a separate method that takes a String as argument and removes all spaces: Input: +0 69 34 55 --> Result: +0693455 [QUOTE] And sometimes the first 0 is missing, and they appear as 868242602. and sometimes they might be in the form +353868242602. [/QUOTE] Then another method that takes …

Member Avatar for FSinister
0
130
Member Avatar for neighbordave

These calculation need to go inside the methods: [CODE] //The getArea method returns the value that is stored in the area field double area = (PI * radius * radius); //Formula to get the area of the circle public double getArea() { return area; } //The getDiameter method returns the …

Member Avatar for stultuske
0
137
Member Avatar for IMtheBESTatJAVA

There is Math.round() that rounds a double: 10.9 --> 11.0 10.4 --> 10.0 If you want a certain number of decimal digits you can: Multiply (for example) the number with 100, then round it with the above method and then divided again with 100: 10.123456 --> 1012.3456 --> 1012.00 --> …

Member Avatar for orko
0
140
Member Avatar for Grub

With the hashCode() you compare objects. It's no different than using equals() So if you use: File.hashCode() or File.equals() you will compare 2 file objects. Now I don't know the rules that these methods were written but I presume that they compare the path of the file they refer to. …

Member Avatar for ~s.o.s~
0
2K
Member Avatar for Aashath

The r.toString() returns a String, it does not print. You need to call System.out.println() with argument r or r.toString()

Member Avatar for darkagn
0
120
Member Avatar for efus

The error has nothing to do with the ArrayList. You forgot to implement the method: suggestions(String)

Member Avatar for stultuske
0
101
Member Avatar for dnmoore

When you have a degree as a parameter you don't know if it is in Celsius or in Fahrenheit. So you will use the scale to determine that and calculate the results accordingly. [U]So don't put any calculations in your get Methods.[/U] When you set the degree (by Constructor or …

Member Avatar for dnmoore
0
2K
Member Avatar for mrjoli021
Member Avatar for daBaki.

[QUOTE=daBaki.;716632]Can someone help me how to read and write text file using Java Code... ??? Thanks in advance..[/QUOTE] Start you own thread. This thread started by someone who had a problem. Now, do you expect people to start helping you and stop answering the other guy's question? Start your own …

Member Avatar for Tbusuk
0
122
Member Avatar for joshmo

You cannot use what you declare in B inside A. Only the other way around since it is B that extends A, so B can access what you declare in A

Member Avatar for Alex Edwards
0
144
Member Avatar for shubhang

[QUOTE=shubhang;717633]I observed that many programmers do not create separate functions. They write the whole program in the main function. [/QUOTE] What do you mean by saying: "many programmers". Because this is not the right way to do it. In any language. You must write small functions that are called in …

Member Avatar for shubhang
0
102
Member Avatar for cproud21

The Employee class has these declared private: private String employeeName; private String employeeNumber; private String hireDate; Since the ProductionWorker extends the Employee you don't need to declare them again in the ProductionWorker class. Declare only these variables: private int shift; private double payRate; Since the first 3 in the Employee …

Member Avatar for javaAddict
0
398
Member Avatar for viber101

You can view a .class file like any other file: By opening it. Use whatever program you want to open it. But don't expect to see anything. Here is a sample of what a .class file looks like when I used PSPad: [QUOTE] CAFE BABE 0000 0031 0112 0A00 4E00 …

Member Avatar for stultuske
0
150
Member Avatar for iheartcoheed129

Also when you try to print the sentence in the end: System.out.println (+text) (remove the '+' of course), the text variable has been modified in the while loop. So you will not print the original sentence. Save the input to one more variable and print that one in the end

Member Avatar for jared_masc
0
126
Member Avatar for cescbayo

Or we can do your Homework since this is the purpose of this forum: [URL="http://www.daniweb.com/forums/announcement9-2.html"]Read this[/URL]

Member Avatar for stultuske
0
118
Member Avatar for praful_engg

Haha that was a good one. [QUOTE]To allo me ton Toto to kseris?[/QUOTE] The above is a greek expression used as a reply to someone who says or asks something stupid or impossible and he thinks that is normal to ask such thing Do we have [I]praful_engg[/I]'s slaves written on …

Member Avatar for stultuske
-1
137
Member Avatar for ezkonekgal

[CODE] BufferedWriter writer = new BufferedWriter(new FileWriter("filename.txt")); writer.write("This is a line"); writer.newLine(); writer.close(); [/CODE] Also: [URL="http://java.sun.com/javase/6/docs/api/java/io/BufferedWriter.html"]BufferedWriter[/URL] [URL="http://java.sun.com/javase/6/docs/api/java/io/FileWriter.html"]FileWriter[/URL]

Member Avatar for stultuske
0
106
Member Avatar for Blackeagle

Type cast Object to Integer: Integer integ = (Integer)objectValue; integ.intValue();

Member Avatar for Ezzaral
0
135
Member Avatar for janamrob

Where one class ends and the other starts? Use code tags and have each class separately

Member Avatar for javaAddict
0
4K
Member Avatar for winky

[CODE] if(Character.isDigit(s.charAt(j))) { //x=(int)s.charAt(j); // Try this and repeat to the other number y char ch = s.charAt(j); x = Integer.parseInt( String.valueOf(ch) ); j++; y=(int)s.charAt(j); z= x + y; System.out.print(z); } [/CODE] After you take the char, if you cast to primitive int it will give you the ASCII. But …

Member Avatar for javaAddict
0
117
Member Avatar for jee85

They sure changed java last time I checked. They made it look like more C. But wait, this is C. Listen this is a java forum, and your code is in C, but the error you get is confusing: [QUOTE]gabor.java class or interface expected[/QUOTE] How are you trying to compile …

Member Avatar for stultuske
0
158
Member Avatar for programmingme

Have you ever written a .java file and compile it by doing: javac file.java ?

Member Avatar for stultuske
0
104
Member Avatar for johanna26

[QUOTE=johanna26;712873]I am new to Java applet.. pls help me out.... I have a very short period to complete this task...[/QUOTE] Since you [TEX]have a very short period to complete this task[/TEX] you should have started studying and writing code sooner, and not wait till the last moment and decide to …

Member Avatar for MoZo1
0
119
Member Avatar for need_Direction

What exactly do you want to accomplish? When you say 3D volume object, you mean Graphics, or just a java class that represents a 3D Rectangular?

Member Avatar for MoZo1
0
169
Member Avatar for ejosiah

You could use: [URL="http://java.sun.com/j2se/1.5.0/docs/api/java/text/DecimalFormat.html"]DecimalFormta[/URL] or try Math.round after you have multiplied the result with 100..00 and then divide t=with the same number depending on the precision you want: [CODE] double result = 0.0999999999; double d = result *1000; d = Math.round(d); d = d/1000; [/CODE]

Member Avatar for javaAddict
0
169
Member Avatar for rainny

Search this forum and you will find many examples on how to connect to the database, even code on how to do the login check

Member Avatar for peter_budo
0
111
Member Avatar for NotThereAnymore

You can first check if the input is 'Q' or 'q' and then try to convert it into a double

Member Avatar for NotThereAnymore
0
860
Member Avatar for codered152

[URL="http://java.sun.com/j2se/1.5.0/docs/api/java/util/HashMap.html"]HashMap[/URL] [CODE] HashMap map = new HashMap(); map.put("ONE",new Integer(1)); Integer integ = (Integer)map.get("ONE"); int value = integ.intValue(); [/CODE] or [CODE] HashMap map = new HashMap<String,Integer>(); map.put("ONE",1); int integ = (Integer)map.get("ONE"); [/CODE]

Member Avatar for javaAddict
0
135
Member Avatar for ttano173

Try this: [CODE] Object[] possibleValues = { "First", "Second", "Third" }; Object selectedValue = JOptionPane.showInputDialog(null, "Choose one", "Input", JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]); System.out.println(selectedValue); [/CODE] I got it from this: [URL="http://java.sun.com/javase/6/docs/api/javax/swing/JOptionPane.html"]JOptionPane[/URL]

Member Avatar for javaAddict
0
192
Member Avatar for scream2ice

Also if you had searched the forum, you would have come up with this post about Stack. Others had the same question as you, so you could have searched to see your question answered [URL="http://www.daniweb.com/forums/thread146631.html"]http://www.daniweb.com/forums/thread146631.html[/URL]

Member Avatar for scream2ice
0
261
Member Avatar for QQYee

How about: public void setListData(Object[] listData) [URL="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html#setListData(java.lang.Object[])"]http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html#setListData(java.lang.Object[])[/URL] Also why not use these constructors public JList(Object[] listData) or public void setListData(Vector<?> listData) [URL="http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html"]http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JList.html[/URL]

Member Avatar for javaAddict
0
188
Member Avatar for krauz2
Member Avatar for countrygirl1970

[CODE] question = questionGenertor (randomValue1, randomValue2); // asking the user a math question boolean wrongAnswer=true; while (wrongAnswer) { results = JOptionPane.showInputDialog (question,""); if (results.equals("" + randomValue1 * randomValue2)) { JOptionPane.showMessageDialog( null, "Very Good"); rightAnswers += 1; wrongAnswer = false; } else { JOptionPane.showMessageDialog(null, "No, Please try again."); } // end …

Member Avatar for javaAddict
0
99
Member Avatar for Blackeagle

If you want to call methods you can only do it inside other methods (a Constructor maybe). Where you wrote the code that gives you the error you can only put variable declarations. So you must declare a method (preferably a Constructor) and put the code that gives you the …

Member Avatar for Blackeagle
0
103

The End.