Fred Kleinschmidt

Bartender
+ Follow
since Oct 13, 2015
Cows and Likes
Cows
Total received
9
In last 30 days
0
Total given
0
Likes
Total received
115
Received in last 30 days
0
Total given
2
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Fred Kleinschmidt

Where you are printing a single asterisk, put a do-loop that goes from j=0 to j<bank and print an asterisk in the body of the loop.
Then when the loop ends, print a newline.
3 weeks ago
Or possibly you are expected to ask the user for two integers (a low and a high),
and then compute and print the factorial of all integers in that range.

So Jeanne's answer would be for the range (1,4).
but your program should allow, for example, (5,13) and print 5!, 6!, ..., 13!
3 weeks ago
Another example of hiding the internal representation can be a Complex number.
You need two values to represent a Complex, but that can be done by storing
the real and imaginary parts (x,y) or
by storing the magnitude and angle (r,theta).

There is no need for you to know which way is being used as long as there is
a way to retrieve x, y, r,  and theta.
1 month ago

Angelos Naoumis wrote:I have never seen any of my instructors using equals.


Wow - this should be one of the first things mentioned when studying about class instances.

You use == to check whether two object references point to the same instance.

You use equals() to determine whether two object instances have the same content (or are considered to be equivalent).
1 month ago
Your program should not hard-code the information to be printed - otherwise it will become obsolete after the last month you include.

You should instead put that information in an external file or database, and the program should read the information from that file.That way you can just update the file and send your frient the updated file, and the program will not have to be rewritten every few months.
1 month ago
You should really be parsing the text character by character as the user types it in, and not accept a character that would be illegal at that position.
1 month ago
First, you should be creating and displaying the frame from the Event thread, not the main thread.

Second, just eliminate the System.exit() call. Then every time you click on the button, the actionPerfomed() method will be executed.

Third, you will need some way to eventually exit the program, such as adding another "Exit" button and adding an event handler to that button, and that nahdler's actionPerformed() method should call  a method that will exit the application.
1 month ago
Perhaps a simpler way iis:
Even better would be to use a StringBuilder instead of String. That way you won't keep creating new String instances for every iteration of the loop.
2 months ago
It might be easier to use a StringBuilder instead of an int array for the binary variable. Then use to prepend the correct character, and finally just print binaty.toString() after the loop exits. This also makes it simpler if you want to use longs instead of ints, so you don't have to guess how big the array needs to be.
2 months ago

German Martinez wrote:f (x) and g (x) must return their values depending on their input parameter x and not on which of the two functions was executed first.


In general, this is not true. If both f() and g() are instance methods, and they both reference and/or modify one or more instance variables, then it is quite possible that the result is not commutative.
Also, if they reference/modify any static variables (even if either f or g or both are static) the order might be important.
2 months ago
Also, do not override the paint() method. You should override paintComponent() instead, and the first statement in that method should be
2 months ago
In your original post, you have the loop:

Iff "a" is "yes" then you will enter the loop. But since you never modify "a" in the loop, you will stay in the loop forever.
2 months ago
There is really no need for the static methods; you can easily do it with two constructors.
Create a domestic student using this c'tor:

and non-domestic using

if the latter one is used passing a null or empty documents value, it would either create a domestic Student, or throw an exception (your choice).
2 months ago
One way is to add a ChangeListener to the slider, and have the stateChanged() method of the listener change the font size of the relevant components.
This works OK fif you are only changing the font of one or two components, and the listener has access to the component references.

A better way is to have the stateChanged() method issue a property change for the font size, and then just add a PorpertyChangeListener to each component whose font size you want to be modified. that way the slider's ChangeListener dioes not have to know about any of the components it will be controlling, and components can be easily added or removed from participating, at run time.
2 months ago
You should not be doing that in main(). All of your variables are instance variables (and rightfully so).
Your run() method creates an instance of Main, and you should use that instance to do all of the work.
Your Main class should have oublic methods that can be used to do things such as adding tabs, etc.
3 months ago