Search:

Type: Posts; User: Zaphod_b

Page 1 of 20 1 2 3 4

Search: Search took 0.08 seconds.

  1. Replies
    5
    Views
    1,155

    Re: One Simple Question

    You can compile any blasted, bloomin' thing you want.

    However to execute a Java application program, you need a public class with a public static void main(String [] args){} method. Like it or...
  2. Re: Need Help for Java Coding in setting duration for parking system.

    Ummm...

    11.59 PM is the last minute before midnight
    12.00 AM is midnight (one minute later than 11.59 PM).
    12.01 AM is one minute past midnight

    11.59 AM is the last minute before noon
    12.00...
  3. Replies
    1
    Views
    1,578

    Re: Can java assign hex values?

    Reference and examples: Primitive Data Types



    Cheers!

    Z
  4. Replies
    4
    Views
    1,079

    Re: Please Help: Random Dice Roll:

    Since '%' is a format specifier, you have to do something special to print a '%' sign.

    Personally, I would spell out "percent" but if you want to print a percent sign, use "%%" in the format...
  5. Replies
    1
    Views
    1,236

    Re: Duplicating default behavior of unix sort

    On my Centos 6.4 Linux system (installed with default US settings) the collator is POSIX.

    So...



    [Zaphod@star5x2 ~]$ locale
    LANG=en_US.utf8
    LC_CTYPE="en_US.utf8"
    LC_NUMERIC="en_US.utf8"
  6. [SOLVED] Re: A linearithmic (at most) complexity algorithm to generate Pythagorean triples

    From the wikipedia article:



    You don't really need a separate explicit parameter for k; you can just let m and n get suitably large and test


    if ((((m - n) % 2) == 1) &&...
  7. [SOLVED] Re: A linearithmic (at most) complexity algorithm to generate Pythagorean triples

    An approach that worked for me: A couple of comments from my Java source:



    //
    // To generate all triples of interest up to a given number:
    //
    // Generate all primitive triples and their...
  8. Replies
    1
    Views
    1,781

    Re: Waveform Generator?

    No, it wouldn't. The argument of the Math.sin method is in radians, so if you have a sinusoidal function with a peak amplitude of 1 and a given frequency in Hz, the value of the function at a given...
  9. Replies
    4
    Views
    1,122

    Re: How to randomize the if loops?

    I'm liking that idea. You could use an array of ints to determine the order in which the things are executed.


    A very simple approach might be something like:



    static void foo(int []...
  10. Re: Creating a Secret Numbers game, need help with random number max and min.

    One more time:

    You have a function whose argument is an int named max.
    You want the function to return a number in the range 1, 2, ..., max.

    My statements used N instead of max.

    Write a...
  11. Re: Creating a Secret Numbers game, need help with random number max and min.

    What I meant was the following:


    To get a number in the range 1, 2, ..., N, here's what you do:


    Call nextInt() with an argument that gives a value in the range 0, 1, 2, ..., N-1.


    ...
  12. Replies
    1
    Views
    1,300

    Re: Dealing With Overflow?

    I'll take a shot.

    First, I must uncover my crystal ball. Stand back, sometimes it gets a little rowdy...

    OK! So far, so good. Apparently Mr. XtalBall is having a good day (so far).

    My...
  13. Re: Creating a Secret Numbers game, need help with random number max and min.

    I don't it will either. In fact I know it won't.

    Consider:

    If you call nextInt(10), you get numbers 0, 1, ..., 9, so nextInt(10)+1 gives a number in the range 1, 2, ..., 10. Right?

    If you...
  14. Replies
    5
    Views
    2,578

    Re: Calculating Pi to more digits?

    That's probably a good thing to investigate, since you are wanting more precision in the terms than Java's built-in double precision variables can give you.


    I don't see the need for BigInteger. ...
  15. Thread: division

    by Zaphod_b
    Replies
    7
    Views
    1,289

    Re: division

    How about starting with an exact, precise problem statement? (Do this before struggling with the ins and outs and variable types and other program considerations.)

    For example, I might want to...
  16. Re: Permanently change variable values based on user input.

    Maybe you can try something like the following:


    When the application starts, have it look for a certain file in a certain place with certain contents.


    If the file does not exist, set...
  17. Replies
    4
    Views
    4,217

    Re: Multi-queue simulation theory

    This is a very general skeleton of implementation of a single-thread simulation program. The pseudo-code for my little time-driven example has a BIG LOOP whose counter value is the number of seconds...
  18. Replies
    5
    Views
    3,086

    Re: Adding polynomials in an ArrayList?

    ...

    I did not want to take it on myself to solve your problem, I merely wanted to suggest that there are a number of ways to approach the problem. If one of my ways doesn't suit your...
  19. Replies
    5
    Views
    3,086

    Re: Adding polynomials in an ArrayList?

    Well, you have to keep track of that somehow.

    The following pseudo-code might indicate one way to do the deed, assuming that all of the exponents are greater than or equal to zero:



    //...
  20. Replies
    1
    Views
    1,216

    Re: ArrayIndexOutOfBounds Help

    Step back from the program a minute and think about what you are trying to do.

    If the number of columns is not equal to the number of rows, you must create a new array.

    For example, suppose the...
  21. Thread: Hangman Game

    by Zaphod_b
    Replies
    1
    Views
    1,532

    Re: Hangman Game

    Well, isn't it waiting for user input? (Why the heck didn't your program tell the user to enter something?)

    Anyhow., in addition to letting the user know what is expected...

    I think it's a...
  22. Re: Finding the lowest integer using sentinellvalue. :( I am stuck!

    I don't see anything in the problem statement that says you have to save all of the values.

    So...

    How about just looking at each entry as it comes in? If it's -1, then quit. If it is not -1,...
  23. Re: Trying to figure out how to use char in this problem.

    Well, as you have, no doubt, discovered, the Scanner class does not have a nextChar() method.

    So, here's something to try:

    In the InternetCharges class, change pkg to be a char and change pkg...
  24. Replies
    5
    Views
    1,175

    Re: for-each loop and a switch statement

    You have a public enum class named Month. Its members are constants that represent the months of the year.

    You have a public class named MonthTest.

    The MonthTest class has

    An instance...
  25. Replies
    3
    Views
    1,552

    Re: 1 class heir from 2 others?

    If you are asking about multiple inheritance (as found in, say, C++) the answer is no, and there are a number of reasons why multiple inheritance is not supported in Java

    Aren't there any...
Results 1 to 25 of 484
Page 1 of 20 1 2 3 4