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 19 of 19

Thread: Request of code for Problems and assignments

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Request of code for Problems and assignments

    could you help me to write this question?

    The Fibonacci numbers are a sequence of integers in which the first two elements are 1, and each
    following element is the sum of the two preceding elements. The mathematical definition of each kth
    Fibonacci number is the following:

    F(k )={ F(k−1)+F(k−2), k>2
    1, k≤2

    The first 10 Fibonacci numbers are: 1 1 2 3 5 8 13 21 34 55
    Write a Java program that uses a for loop to compute and print the first 20 Fibonacci numbers.

  2. #2
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Methods with Parameters & Scanner Objects

    could you help me to solve this question?

    Write a Java program that has a method called quadratic which solves quadratic equations and prints
    their roots. Quadratic equation is a polynomial equation in terms of a variable x of the ax^2+ bx + c = 0.
    The formula for solving a quadratic equation is:

    x=−b±√b^2−4 ac/2a

    Some example equations and their roots are:
    x^2 – 7x + 12 (a = 1, b = -7, c = 12): the roots are x = 4, and x = 3
    x^2 – 3x + 2 (a = 1, b = -3, c = 2): the roots are x = 2, and x = 1
    The program should prompt for the values of coefficients a, b and c from a user by using Scanner object. Then, the method quadratic() should accept these coefficients as parameters and should printthe roots of the equation.

  3. #3
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Text Processing

    could you help me to solve this question?

    Write a Java program that has a method called printPalindrome which accepts a Scanner object for the console as a parameter, prompts the user to enter one or more words, and prints whether the entered String is a palindrome (i.e., reads the same forward as it does backward, like “adanada”, or “racecar”). The method should treat the given String as case-insensitive, so that words like “MaDam” and “RacECAR” will be considered palindromes.

  4. #4
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Method with a return value & Conditional Execution

    could you help me to solve this question?

    Write a Java program that has a method called season() which takes as parameters two integers representing a month and day, and returns a String indicating the season for that month and day. Assume that the month is specified as an integer between 1 (for January) and 12 (for December). Likewise, the day of the month is a number between 1 and 31 (you may consider each month has 31 days, for simplicity). If the given date falls between 12/16 (i.e., December/16) and 3/15 (March/15), the method should return “Winter”. If the date falls between 3/16 (i.e., March/16) and 6/15 (i.e., June/15) , the method should return “Spring”. If the date falls between 6/16 (i.e., June/16) and 9/15 (i.e., September/15) , the method should return “Summer”. And, finally, if the date falls between 9/16 (i.e., September/16) and 12/15 (i.e., December/15) , the method should return “Fall”. The season() method should use conditional statements (e.g., if/else if/…) to determine the result. The program should prompt for month and day information from a user, by using a Scanner object.

  5. #5
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Find the mistakes java exercise

    The following method attempts to return the median (middle) of three integers, but it contains logic errors. In what cases does the method return an incorrect result? How can the code be fixed?
    public static int medianOf3(int n1, int n2, int n3){
    if(n1 < n2){
         if (n2 < n3){
                return n2; 
                } else{
                return n3;
              }
                }else{
                if(n1 < n3){
                  return n1;
                      }else{
               return n3;
                }
                      }
             }
    Last edited by Norm; April 28th, 2021 at 07:50 AM. Reason: Moved / to front of end tag

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default re: Request of code for Problems and assignments

    Yes, we can help you get your code to work.
    http://mattgemmell.com/2008/12/08/what-have-you-tried/

    Be sure to wrap all posted code in code tags.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Methods with Parameters & Scanner Objects

    Yes, we can help you get your code to work.
    http://mattgemmell.com/2008/12/08/what-have-you-tried/

    Be sure to wrap all posted code in code tags.
    If you don't understand my answer, don't ignore it, ask a question.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Text Processing

    Yes, we can help you get your code to work.
    http://mattgemmell.com/2008/12/08/what-have-you-tried/

    Be sure to wrap all posted code in code tags.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Method with a return value & Conditional Execution

    Yes, we can help you get your code to work.
    http://mattgemmell.com/2008/12/08/what-have-you-tried/

    Be sure to wrap all posted code in code tags.
    If you don't understand my answer, don't ignore it, ask a question.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Find the mistakes java exercise

    http://mattgemmell.com/2008/12/08/what-have-you-tried/

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Find the mistakes java exercise

    i fixed it. is it okay now? i can also share my pdf file that contain these questions.

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Find the mistakes java exercise

    What have you tried to do to solve this problem?

    Before writing any code, work out in English what steps are required to solve the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Find the mistakes java exercise

    kinda complicated for my side thats why i want to ask these questions

  14. #14
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default re: Request of code for Problems and assignments

    there is no code in this question, just a story helps the structure

  15. #15
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Find the mistakes java exercise

    Forget about writing any code.
    How would you solve the problem with 3 coins of different values laid on a table in a row left to right. How would you compare them (two at a time) to find the position of the coin of middle value?
    After two coins are compared, what does that tell you about one of the coins possibly being the middle one?
    What further test and results are needed to find the middle coin?

    Hint: The middle coin will be greater than one of the other two coins and less than the other coin.
    If you don't understand my answer, don't ignore it, ask a question.

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default re: Request of code for Problems and assignments

    What is your question about java programming?
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Apr 2021
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default re: Request of code for Problems and assignments

    my aim is write a program within the given information but it would be better for me to get a direct answer. cuz I just want to learn structure with examples

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default re: Request of code for Problems and assignments

    it would be better for me to get a direct answer. cuz I just want to learn structure with examples
    Sorry, this site does not write code examples.
    Try asking Google
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default re: Request of code for Problems and assignments

    Op has not shown any interest in trying to work on these problems.
    Moving to abandoned threads area.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. code to post JMS Request on Queue
    By indiareks in forum Member Introductions
    Replies: 0
    Last Post: January 7th, 2014, 01:23 PM
  2. Replies: 1
    Last Post: November 21st, 2012, 03:27 AM
  3. xml request in java code
    By ridg18 in forum Java Theory & Questions
    Replies: 10
    Last Post: August 9th, 2012, 08:39 AM
  4. Looking for practice problems/assignments
    By tkgraham in forum Member Introductions
    Replies: 2
    Last Post: April 4th, 2011, 10:28 PM

Tags for this Thread