Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java programs

  1. Oct 31, 2008 #1
    can anyone help in solving this program.....

    write a program to create the series as 0 ,3 ,8 ,15 ,24 ,35........till n terms
     
  2. jcsd
  3. Oct 31, 2008 #2

    uart

    User Avatar
    Science Advisor

    Tell us if you have discovered the "pattern" in those numbers yet? Once you know the pattern then I think the program to generate those numbers should be very easy.
     
  4. Oct 31, 2008 #3

    CRGreathouse

    User Avatar
    Science Advisor
    Homework Helper

    Here's a Pari program you can convert:

    Code (Text):
    seq(n)=print1(0);for(k=1,n-1,print1(" ,"if(k%6,[3,8,15,24,35][k%6],0)))
    Output for seq(20):
    Code (Text):
    0 ,3 ,8 ,15 ,24 ,35 ,0 ,3 ,8 ,15 ,24 ,35 ,0 ,3 ,8 ,15 ,24 ,35 ,0 ,3
     
  5. Oct 31, 2008 #4
    i understood the pattern as the difference between the series is like series of odd numbers...i don't know wat r u thinking it at as.....the reply u have given cannot be used in java...

    can u help me to understand better...please
     
  6. Oct 31, 2008 #5

    uart

    User Avatar
    Science Advisor

    Yes that's good, you could certainly implement that pattern in java. Have you made any attempt to implement it yet?

    There is actually an even easier pattern to those numbers (other than the "difference = increasing sequence of odd numbers" one that you've already found).

    Here's a hint: What do you get when you expand and simplify the expression [itex](n+1)^2 - n^2[/itex] and how does this relate to a sequence of increasing odd numbers?
     
  7. Oct 31, 2008 #6
    i didn't get it...sorry
     
  8. Oct 31, 2008 #7
    thank you sir...i got it ...as you said it......

    thank you very much....

    i need you help in another one like that....it says

    write a program to print the following series as
    55555
    54444
    54333
    54322
    54321
     
  9. Oct 31, 2008 #8
    55555-54321 = ?
    54444-54321 = ?
    54333-54321 = ?
    54322-54321 = ?
    54321-54321 = ?

    Find relationship

    so values ...f(x) = g(x) + 54321

    run a simple for loop
     
  10. Nov 1, 2008 #9
    thank you sir,,,,,i am very thankful of yours to help me out in this crucial way......

    thanks a lot.....

    u r amazing
     
  11. Nov 1, 2008 #10
    sir i just want to clarify one statement that i am not able to understand......and that is

    there is question regarding incometax which we have to make a program on java


    a company has employees who are divided into four grades as follows :
    grade basic DA(of basic) HRA(of basic)
    1 10000 or more 40% 30%
    2 5000 - <10000 40% 25%
    3 <5000 but >2000 30% 20%
    4 <= 2000 30% 15%

    this statement....

    "if the net salary which is the total of BASIC ,DA ,HRA is above Rs 50,000 per month then incometax at the rate of 30 % of the annual salary exceeding Rs 50,000 is deducted on monthly basis at source."

    Taking the name of the employees and the basic monthly pay as inputs , a pay slip which contains name, grade , basic monthly pay ,DA , HRA , monthly income , net monthly salary , for employee is to be printed ....write a program to perform this job..

    Sir....how can we find income tax at monthly basis...? when we are given to find it at annual basis....
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Java programs
  1. Java Programming (Replies: 12)

Loading...