171 Posted Topics
Re: 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 … | |
Re: 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.) | |
Re: 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] | |
Re: [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. | |
Re: 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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [I]Hmmmm....[/I] [QUOTE=JeffGrigg;1686776](And with respect to the next error message, remember 'System.out.' ;) )[/QUOTE] :-/ | |
Re: 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: | |
Re: You can't have a dot (.) in your class name. Remove it or use underscore (_) instead. | |
Re: [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 … | |
Re: 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 … | |
![]() | Re: 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 … |
Re: 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 … | |
Re: [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 … | |
Re: There is something to be said for throwing an 'IllegalArgumentException' if the data is invalid. | |
Re: 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 … | |
Re: 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 … | |
Re: 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, … | |
Re: 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. … | |
Re: 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] | |
Re: 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? | |
Re: Don't use '==' to compare string values. Use the '.equals' method. | |
Re: [url]http://stackoverflow.com/questions/652486/dynamic-querystring-in-jrxml[/url] | |
Re: 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 … | |
Re: 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 … | |
Re: 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; … | |
Re: [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 … ![]() | |
Re: 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. … | |
Re: 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 … | |
Re: [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, … | |
Re: 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) … | |
Re: I recommend studying Design Patterns. And Refactoring. This will build skills that you will use constantly. | |
Re: 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)' … | |
Re: 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. | |
Re: 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) { ... … | |
Re: 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] | |
Re: 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, … | |
Re: 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 … | |
Re: [url]http://stackoverflow.com/questions/3449826/how-do-i-find-the-inverse-tangent-of-a-line[/url] | |
Re: 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 … | |
Re: 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 … | |
Re: 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.) … | |
Re: [url]http://lmgtfy.com/?q=playfair+cipher+java+source+code[/url] | |
Re: [url]http://en.wikipedia.org/wiki/SHA-1[/url] | |
Re: 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 … | |
Re: 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, … | |
Re: 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] | |
Re: 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. |
The End.