Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How do you create a mathematical sequence?

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do you create a mathematical sequence?

    I want to declare integers, while the program is running.

    I run the program and then I give it via System.in.println an integer and repeat this as long as I want. I want the program to give those integers a name of a certain type for, for example a(i) or a[i], dunno, (it should be handy) and then a(i) represents the the i'th integer I gave the program. My idea is then that I can use those elements by their name just like, if I had declared them in the first place. For example add two integers together. For example I defined a method add+, which waits for 2 integer and then adds them. For example I write:

    add

    a(2)

    a(47)

    (then I would get here the result.)

    I don't think implementing the add function is difficult. However I don't know, how to let the program count the number of inputs or how to let it declare and use variables.


  2. #2
    Junior Member
    Join Date
    Sep 2014
    Posts
    21
    My Mood
    Cheeky
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: How do you create a mathematical sequence?

    What have you written thus far?
    Toss it between some code tags.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: How do you create a mathematical sequence?

    Well, you would have to write some way to store those values in variables. Perhaps a map might be useful to you if the user can declare the variables names. You also need to be able to parse the Strings.

Similar Threads

  1. Not able to get mathematical calculation in each row
    By brijesh_lo in forum Other Programming Languages
    Replies: 2
    Last Post: August 30th, 2014, 04:23 AM
  2. Not able to get mathematical calculation in each row
    By brijesh_lo in forum Member Introductions
    Replies: 1
    Last Post: August 30th, 2014, 03:37 AM
  3. Using BigDecimal for Mathematical Formulas
    By cooljava50544 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 21st, 2014, 03:05 AM
  4. Mathematical problem with Money amounts
    By craigjlner in forum What's Wrong With My Code?
    Replies: 7
    Last Post: March 19th, 2013, 03:12 AM
  5. Java:Evaluation of Mathematical Expression only from left to right only.
    By deepakl_2000 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: July 15th, 2011, 07:35 AM

Tags for this Thread