gusano79 247 Posting Shark

...
How do I write program to use both the current and previous values for volume? Im sure it can be done, I just can't figure out how to do it.
...

If you only need one previous value, there is a simple answer to your question: Use two volume variables.

It looks like you already have two, i.e. V and V2, but you're only using one of them. I'd rename V2 something more descriptive, like OldV or something, and make it so V has a value before you start the loop. The only addition to the loop would be to add a line at the start that says 'OldV = V;'--then you can do whatever you want with V in the loop body, since you've already stored the previous value. Once you've calculated a new value for V, you can use both the current and previous values as much as you want. OldV will only ever hold the most recent value of V.

Hope that helps.
--sg

gusano79 247 Posting Shark

also it could be

do
{
// action
}
while( condition )

As long as the condition is true the first time it is tested, you're right--the loop behavior is the same. But a for loop always tests the condition before entering the loop body; the above loop tests the condition after, which guarantees that the code inside the loop will run at least once. In contrast, if the condition is false the first time around, a for loop will never execute the loop body.

Example--the second printf statement will never be reached. A clever compiler might toss up a warning:

#include <stdio.h>

void main(void)
{
	printf("before loop\n");

	for(int i = 4; i < 2; i++)
	{
		printf("    argh! in de loop!\n");
	}

	printf("after loop\n");
}
gusano79 247 Posting Shark

Is that code complete/correct? The two questions don't make much sense. Both ask how many times the while loop iterates, but what is k supposed to be? And look at the for loop closely--how many times will that loop really run? (only two answers to that, depending on what n is and assuming the body of the while loop doesn't change the value of j)

You can try different values for n, but it's more of a tool for understanding how the loop works--there isn't really any "correct" value.

On the chance you haven't done this yet, you can replace any for loop with an equivalent while loop. Both of these loops accomplish the same thing:

for(<initial>; <condition>; <action>)
{
    // loop body here
}
<initial>;
while(<condition>)
{
    // loop body here

    <action>;
}

Expanding loops this way and then going through each step by hand should help.

--sg

gusano79 247 Posting Shark

Programming languages are all fundamentally equivalent; try a few and pick the one that makes the most sense to you. As far as which one that might be, here's my $0.02:

BASIC was designed to be a beginner's language (that's what the B is for). VB has outgrown that purpose somewhat, but is still a decent spot to start. It's especially useful if you're interested in customizing the behavior of MS Office products.

Pascal is another teaching language. Outside of learning how to write software (which it is good for), it doesn't appear to have much use any more. On a personal note, Pascal drives me nuts.

C might work as a starting point. It's a "dangerous language" if you use features (like pointers) that you don't quite understand, but I wouldn't avoid it for that reason. If you starh here, you might as well go for C++; it's a superset of C. Start with C, get comfortable with it, and then start adding features from C++ without changing compilers.

Python! I like Python. You can use it straight from an interpreter and get instant feedback while you're learning. It also exposes just about everything in the program environment if you want to see what's really going on under the hood.

gusano79 247 Posting Shark

As an exercise in procrastination and boredom, I found a thread over two years old and posted a reply.

gusano79 247 Posting Shark

national -> debt

gusano79 247 Posting Shark

You already have the conceptual model, which defines the relationships between the entities you're modeling. A logical model addresses the organization of data within that model, i.e. what tables and fields will actually be created and how they relate to one another (the "Relationships" diagram in MS Access is one example). Then from there you create the physical model, which is the database itself.

Depending on who you ask, the difference between a conceptual model and a logical model can be rather blurry. I prefer to keep the conceptual model on the semantic side of things, focusing on the real-world entities and their meaning; the logical model would be more syntactic, focusing on the structure of the information and some implementation details.

Does that help?
--sg

gusano79 247 Posting Shark

One reason why your memory buttons don't work: The array you're using to store the values is declared in the actionPerformed method. This means that as soon as the method returns, the array goes away forever. If you move the declaration somewhere with a larger scope, e.g. make it a member of your Calculator class, the stored values will stick around after the action processing has finished.

gusano79 247 Posting Shark

... the constant blinking that occurs when the repaint method is called has become quite annoying! ...

Yes it is, especially if you're epileptic.

Quick explanation: When you call repaint, that ends up placing a call to update, which does a fillrect to clear the drawing area and then calls paint. To get rid of the clearing on each frame, you have to override the update method of your applet (or whatever class your drawing surface lives in) so it simply calls your paint method:

public void update(Graphics g)
{
     paint(g);
}

This stops the flicker, but creates more work for you. If you don't clean up the previous frame, your targets will leave slimy trails everywhere. For moving objects, there's usually substantial overlap between frames, so you can draw the new object over most of the old one and only erase the part that's left over. If you look closely enough, you'll be able to see this happening, but it's nowhere near as noticeable as the flicker problem you're having.

If you want it really smooth, use a double buffer. Have a look at java.awt.Image; you can draw to an off-screen graphics context for each frame and zap it into the applet once you're finished. Then flicker doesn't matter because you'll never actually see the drawing operations happening--you only get the final image each frame.

gusano79 247 Posting Shark

Yep, the cable modem is second-hand and showing its age. I think it's the only component I'm using that isn't 10/100. Might have to "accidentally" drop it in the lake...

gusano79 247 Posting Shark
...
Thread th_ciz;
...	
th_ciz=new Thread(this);
...
bt_ciz.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent ae){
		th_ciz.start();
	}
});

Try this:

Remove the declaration and definition of th_ciz (first two lines quoted above). Roll it all into the ActionListener:

bt_ciz.addActionListener(new ActionListener(){
	public void actionPerformed(ActionEvent ae){
		(new Thread(this)).start();
	}

Hm, that should work. If the anonymous thread isn't quite right, you can always stash it in a local Thread variable instead.

I think that's what you're asking about... So if all you're doing in the Run method is calling repaint(), is there a good reason you can't do that from the button's handler?

gusano79 247 Posting Shark

... create a target with a recognizable boundary ... I need the boundary to be the exact shape of the circle ... Am I approaching this the right what? Do I need a special algorithm?

All of that "isInQuad" setup is more complicated than it has to be, and it will be a nightmare to maintain if you want to change anything.

If it's a circle you want, a little coordinate geometry should do the trick:

public boolean isInCircle(int x, int y, int left, int top, int diameter)
    /*
     *    test whether point (x, y) is inside a circle.
     *    specify (top, left) coordinate of bounding rectangle.
     *    diameter covers both the width and height values.
     */
{
    int radius = diameter / 2;
    int center_x = left + radius;
    int center_y = top + radius;

    int x_distance = x - center_x;
    int y_distance = y - center_y:

    return ((x_distance * x_distance) + (y_distance * y_distance) <= (radius * radius));
}

I've left in a bunch of intermediate values to make sure the math isn't that badly obfuscated--it could be smaller and faster. I did leave off the square roots in the final distance calculation, though, which works fine because you don't need the exact distance, just an "in" or "out" determination; f(x) = x^2 is monotonic, so the "<=" comparison is still valid. Speaking of which, "<=" counts anything right on the edge as on the circle, while a "<" wouldn't. Pick your favorite.

--sg

gusano79 247 Posting Shark

Finally found the problem. Buried in the router configuration was a little bit about the WAN connection speed. Dropped it from 100 mbps to 10 mbps and now everything goes smooth with a capital SMOO. I had no idea I needed to explicitly set one or the other; the router manual doesn't mention it at all. I only found it because I was randomly going through the config pages. Be ye warned...

Thanks everyone for your assistance
--sg

gusano79 247 Posting Shark

A simple reset of your modem should work here.
...
TKS

Operative word = "should"

... ISP may have MAC address assignments at the DHCP level. ...(might be the case with static IP). ...
TKS

I get my IP dynamically, but could they still pull the the MAC ID from my NIC through the modem? I'll check and see if that's the case.

thanks
--sg

gusano79 247 Posting Shark

... power off the modem and router for thirty seconds. Power up the modem. Give it 45 seconds or so to warm up. After that, plug in the router to the modem. ...

Done that a few times, but it's good to verify I'm not missing something there. I've left them off for quite a bit longer; the SURFboards, I'm told, usually need more time. I'll give it another go to see if it magically fixes itself.

thanks
--sg

gusano79 247 Posting Shark

I have a wireless router (D-Link DI-524) and a cable modem (Motorola SURFboard 3100) which I cannot get to talk to each other. The modem works beautifully when connected to the computer via my Ethernet device (as it is right now), and the wireless router is also performing as expected on its own. When I try to connect the two, it appears that they don't want to communicate.

When I turn on the router, it appears to be exchanging some sort of data with the modem (flashing WAN light) for a few seconds, and then the light abruptly goes dead and stays that way. From the HTML configuration interface for the router, it looks like it can't find a DHCP server on the WAN connection.

The configuration page on the modem reports that everything is okay. It lists my Ethernet device's MAC ID as a known address, but nothing else. It reports that the onboard DHCP server is enabled.

All IP addresses are dynamic; the modem gets one from my ISP, the router is *supposed* to get one from the modem, and computers on the network get theirs from the router.

The most common answer I've seen to this sort of problem is that the modem has become somewhat fixated on the Ethernet device's MAC ID and needs some time to learn that of the router. I've tried all the sane permutations of the solutions I've found and given it plenty of time, but so far …