171 Posted Topics

Member Avatar for wallet123

To successfully complete an assignment like this, you need to be able to break it down into smaller problems. You need to be able to recognize patterns in the inputs and outputs you want, and use those patterns to simplify the code. In this assignment, you also need to know …

Member Avatar for wallet123
0
714
Member Avatar for Ashenvale

It's generally bad form to use the index of a 'for' loop, like 'ctr', outside the loop. Your problem is that your four-line "if" statement is outside the loop. It executes only once. ('totalRec = ctr;' is correct. But I might suggest using 'totalRec = studNo.length;' instead.)

Member Avatar for stultuske
0
136
Member Avatar for Ashenvale

There's something to be said for... [CODE]System.out.println("Student No. Name Course Sex"); ... System.out.printf("%-11s %-10s %-6s %1s\n", studNo[ctr], studNa[ctr], course[ctr], sexCode[ctr]);[/CODE]

Member Avatar for JeffGrigg
0
130
Member Avatar for axim0

[QUOTE=~s.o.s~;1717214]Is that the same connection variable you are using for all of them?[/QUOTE] Yes. Use different variables. Or method calls. Or a loop. Or something. Also, you really only need to do 'Class.forName("com.mysql.jdbc.Driver");' once, at the beginning.

Member Avatar for ~s.o.s~
0
705
Member Avatar for chinee

That it says "cannot find symbol" instead of "The constructor Product(String, double) is undefined" suggests that you need to figure out how to compile multiple source files together, so that the compiler can work out the inter-file dependencies. When you fix that, and get the 'constructor undefined' error, you'll have …

Member Avatar for zeroliken
0
344
Member Avatar for gourav1

[QUOTE=gourav1;1715375]... means i have to make every .java file for a class if i want to make it public ? means i have mistaken by making 2 classes as public in a same .java file ? right ?[/QUOTE] Yes. Every public Java class must be in its own file. Don't …

Member Avatar for gourav1
0
123
Member Avatar for nchy13

In Java, you should normally put one class in each file. The branchpredictor class should be in a file called "branchpredictor.java". Move lines 1 through 300 of your example to that file. (Alternately, you could make it 'private' instead of 'public'. Or make it an inner class. But those are …

Member Avatar for nchy13
0
349
Member Avatar for limpek1991

One thing that you will learn about computers is that they will always do [B]exactly[/B] what you tell them to do. ...even when that's [B]not[/B] what you want. So you've asked the computer to [B]continue[/B] doing the loop [B]while[/B] the Registrant (number) [B]is equal to zero[/B]. Is that what you …

Member Avatar for limpek1991
1
125
Member Avatar for lele07060

[I]Hmmmm....[/I] [QUOTE=JeffGrigg;1686776](And with respect to the next error message, remember 'System.out.' ;) )[/QUOTE] :-/

Member Avatar for JamesCherrill
0
527
Member Avatar for domingur

For “Honda Civic”, "Honda" is the [B]make[/B] [I](who made it)[/I]; "Civic" is the [B]model[/B] [I](what kind of car it is).[/I] That should help [I]just a little.[/I] :icon_mrgreen:

Member Avatar for JeffGrigg
0
722
Member Avatar for lele07060

You can't have a dot (.) in your class name. Remove it or use underscore (_) instead.

Member Avatar for JeffGrigg
0
83
Member Avatar for ITHope

[QUOTE=ITHope;1686292]So my java pprgram is actually a GUI I did all of it except I cant figure out how to convert between bases example: number=2239 base=3 newbase=4 first i need to convert 2239 to base 3 which would be 2 * 3^3 + 2* 3^2 + ..... then convert that …

Member Avatar for JeffGrigg
0
115
Member Avatar for akingcool

Generally, I would recommend using the Apache POI library to read Microsoft Office files, including Word documents. [url]http://poi.apache.org/[/url] Or if running on Windows, one could use ActiveX to drive the Word program directly. Neither of these is very accessible for a beginner. Something that might be possible for you is …

Member Avatar for akingcool
0
419
Member Avatar for mehnihma

In software development, you will find it very helpful to clearly describe the problem. It doesn't just help us help you; it will help you think clearly about the issue, and how to solve it. So your problem is that once you enter correct values for grade and number of …

Member Avatar for stultuske
0
125
Member Avatar for seanbl1

I assume that your instructor provided you with the "EasyIn" class. I don't know exactly what it does, but a common problem is that such methods might get the new line ('\r' and '\n') characters that occur at the end of each line. If you still have problems, consider using …

Member Avatar for JeffGrigg
0
107
Member Avatar for marco1497

[QUOTE=marco1497;1677937][B]Why are programming languages dissimilar even if they go after the similar compilation procedure?[/B] [I]>>>elaborate on the compiler design part NOT on the Structure/Concept of Programming language side<<<[/I][/QUOTE] The question doesn't really make a lot of sense. Different compilers for the same programming language often have different compiler designs. Consider …

Member Avatar for JeffGrigg
0
257
Member Avatar for Joey_Brown

There is something to be said for throwing an 'IllegalArgumentException' if the data is invalid.

Member Avatar for Joey_Brown
0
3K
Member Avatar for EricaMitchell

To find all the prime numbers less than N... Well, '1' isn't a prime number. '2' is the first prime number. So maybe we could write a loop that counts from '2' up to the largest number that is just less than 'N'. Now that we have a number, let's …

Member Avatar for anas2ahmad
0
99
Member Avatar for ali11

A 'switch-case' statement?!? Dude; you are confused. Your code already has a bunch of listener classes wired up correctly. The system is already dispatching to the appropriate methods. What's stopping you from putting the code in the methods you've created for that purpose?!?!?!?!? ;) To make progress, you need to …

Member Avatar for JeffGrigg
0
2K
Member Avatar for some00001

I think that the student is trying to implement a binary search. It seems that the user has selected a number in the range [1..100] and the computer must guess it. I assume that after each guess, the user tells the computer if the guess was less than, equal to, …

Member Avatar for DarkLightning7
0
91
Member Avatar for .Tyler

First, you need the score to be in a variable, so that you can work with it. So I'd start by making this change: [CODE] int testScore = inputStream.nextInt(); System.out.println("Line " + lineNum + ": " + testScore);[/CODE] Then you'll need if statement(s) to determine if the scores are valid. …

Member Avatar for JeffGrigg
0
105
Member Avatar for kelvin924

To get the appropriate "\n", "\r" or "\r\n" [I](or other!)[/I] string for your platform, see... [url]http://stackoverflow.com/questions/207947/java-how-do-i-get-a-platform-independent-new-line-character[/url]

Member Avatar for JeffGrigg
0
87
Member Avatar for torkolort

There's a lot to be said for using something that is simple and obviously correct. There is also a lot to be said for testing. I recommend automated testing using JUnit. Example: Should 'deltekst("abc", "abc")' return true? Does it?

Member Avatar for JamesCherrill
0
169
Member Avatar for geekman89
Member Avatar for geekman89
0
110
Member Avatar for Pravinrasal
Member Avatar for JeffGrigg
0
167
Member Avatar for herstein

Suppose you are looking at a range of values between the indexes "left" and "right." You look at a value in the middle of the range and decide that you want to move left -- the to the left of the middle are closer to the target value that you're …

Member Avatar for herstein
0
114
Member Avatar for swoshromp

Your nested loops are confusing you. What you have looks like this: [CODE] String word = { Get the next word. }; // make while loop to count down the loss of the user int maxTries = 6; while (maxTries > 0) { { Clear out guesses. Start guesses for …

Member Avatar for JeffGrigg
0
259
Member Avatar for onyx112

It never makes it into the loop in the 'L3Creator' method. Presumably 'L1[0] * L2[0]' will be non-zero, but 'L3[0]' will be zero, so the '==' test will return false. I suspect that this is what you want: [CODE] for (index1 = index2 = index3 = 0; index3 < L3.length; …

Member Avatar for JamesCherrill
0
123
Member Avatar for pikalife

[QUOTE=jackmaverick1;1681263]Really, I though it was a goto line statement. Meaning it gives command to the line specified. [URL="http://stackoverflow.com/questions/2545103/is-there-a-goto-statement-in-java"]Stack Overflow article[/URL][/QUOTE] As it points out, "goto" and "const" are reserved words in Java, but not implemented. They are reserved and implemented in C and C++ -- the languages which primarily inspired …

Member Avatar for hfx642
0
8K
Member Avatar for ali11

Nothing? It throws 'java.util.EmptyStackException' every time I press it. ;) Probably has something to do with the fact that the 'enterHandler' class is not used anywhere. Once you deal with that, I have to question why you're doing 'if (cStack.pop().equals("+")) {'. Most RPN calculators only put numbers on the stack. …

Member Avatar for JeffGrigg
0
767
Member Avatar for subone

If you want to print the numbers the user entered after they're done entering them, they you'll have to store the numbers somewhere. Students most commonly do this with an array. I think that your sum and average logic are OK. But if you test your program carefully, you'll probably …

Member Avatar for JeffGrigg
0
262
Member Avatar for hannah shrn j

[LIST=1] [*]Remove the space from inside the class name [ICODE]IO Exception[/ICODE]. [*]Change [CODE]while(cont==1)[/CODE] to [CODE]} while(cont==1);[/CODE]. It's not in the right place to match the leading [ICODE]do { ...[/ICODE] statement. And as the end of a statement, it needs a terminator. And you're short one closing brace ('}'). [/LIST] That, …

Member Avatar for JeffGrigg
-1
262
Member Avatar for dhani09

For example... [CODE] // (sum[j] holds max of all sums ending in A[j]) maxsum := A[1] // This line is a quick constant-time operation. It's 'O(1)' create array sum[n] of n size // This line could be "slow" but can be considered 'O(1)' or 'O(C)' (where 'C' is some constant) …

Member Avatar for JeffGrigg
0
128
Member Avatar for chiiqui

I recommend studying Design Patterns. And Refactoring. This will build skills that you will use constantly.

Member Avatar for JeffGrigg
0
235
Member Avatar for Stjerne

I don't see a problem. You may have to do some debugging, to verify your assumptions. My best guess is that you're not setting the bicycle field on the Person instance when they're checking out the bicycle. Use a debugger and/or print statements. (Aside: I notice that the 'deliver(Person s)' …

Member Avatar for Stjerne
0
831
Member Avatar for lele07060

You need to try to do the assignment first. If you run into problems with the code, then post it here with a specific question, and we can help you. You need to learn how to input data and do simple operations on it.

Member Avatar for JeffGrigg
0
3K
Member Avatar for lbgladson

Have you learned anything about what methods you can use on the "Scanner" class? [I](Like ".nextInt()" maybe? ;-)[/I] If you want to keep asking them the question until they give you a valid value, then you will need some form of looping. Me, I'm partial to 'while (true) { ... …

Member Avatar for stultuske
0
170
Member Avatar for pseudorandom21

Generally it's the number between the percent sign ('%') and the letter. ...much as you would see in the C 'printf' function. [CODE] StringBuilder sb = new StringBuilder(); Formatter formatter = new Formatter(sb, Locale.US); formatter.format("/%10d/", 23421); System.out.println(sb.toString()); [/CODE] Produces this output: [ICODE]/ 23421/[/ICODE]

Member Avatar for stevanity
0
141
Member Avatar for ali11

You probably want to [ICODE]import java.util.Stack;[/ICODE] and maybe have [ICODE]private Stack<Integer> myStack = new Stack<Integer>();[/ICODE] [I](Or make it a Stack of <Double>, perhaps.)[/I] And then you need to think carefully about what should be on the stack, and when to push and pop things to and from the stack. Like, …

Member Avatar for JeffGrigg
0
294
Member Avatar for lbgladson

JUnit is designed to handle this. There's an extra optional parameter just for floating point values: [CODE] Assert.assertEquals(523.5987755982989, sphere.getVolume(5), 0.00000000000001);[/CODE] [I](Make sure that 'getVolume' returns a 'double' value.)[/I] [I](Note: Also, it's silly for the Sphere class to take the radius as both a constructor parameter and a parameter to the …

Member Avatar for JeffGrigg
0
188
Member Avatar for Labdabeta

[url]http://stackoverflow.com/questions/3449826/how-do-i-find-the-inverse-tangent-of-a-line[/url]

Member Avatar for Labdabeta
0
413
Member Avatar for hhagood

You need to at least try to write the program. We'll help you, but we won't do it all for you. If you were awake during class or read some of the book, then you should have learned something about creating a class with a "main" method in it. Start …

Member Avatar for Ezzaral
0
451
Member Avatar for pradeep_java

The number of atoms in the observable universe is about 10^80. That's 100000000000000000000000000000000000000000000000000000000000000000000000000000000. That's about 80 digits. I'm not sure what one might be counting that you would need 1000000 [U][B]decimal digits[/B][/U] to count them. ;-> So: BigInteger can do it. Also, assuming that there are a much smaller number …

Member Avatar for JamesCherrill
0
1K
Member Avatar for tootiemae

This looks like a homework assignment. You will have to figure out how to create a class with a "main" method, and to run it. You will have to figure out how to print data to the user (System.out.println), and receive data from the user. (Using a "scanner" is popular.) …

Member Avatar for k-broxe
0
246
Member Avatar for Sai Sotes
Member Avatar for Sai Sotes
0
344
Member Avatar for mhamy
Member Avatar for Stjerne

Another idea on how to achieve uniqueness: Do it like cards in a deck: Generate the numbers 100 to 1000 and put them, in order, in an array of 901 elements (0 to 900). Then "shuffle" them: For each element, from 0 to 900, swap that element with a randomly …

Member Avatar for JeffGrigg
0
166
Member Avatar for ynwa

Variables declared in the 'try' block can't be seen outside of it. Try this: [CODE] import java.awt.*; import java.awt.image.*; import java.awt.geom.*; import java.lang.Exception.*; import java.io.*; import javax.imageio.*; import javax.imageio.ImageIO; import java.net.*; import java.net.MalformedURLException; class Blur1 { public static void main(String[] args) throws Exception { float[] matrix = { 0.111f, 0.111f, …

Member Avatar for stultuske
0
609
Member Avatar for 5minutes

Here's an example of a relevant JUnit test: [CODE] import junit.framework.TestCase; public class FunTest extends TestCase { public void testZeroCelsiusToFahrenheit() { double celsius = 0.0; assertEquals(32.0, Fun.fahrenheit(celsius)); } } [/CODE]

Member Avatar for JeffGrigg
0
171
Member Avatar for schoolboy2010

The main problem is that the right brace ('}') on line 20 needs to be moved to the end of the file. You want ONE '}' to close the main method. And right after that you want the 'public ... inputGetter ....' procedure.

Member Avatar for JeffGrigg
0
4K

The End.