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

# Thread: Request of code for Problems and assignments

1. ## 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. ## 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. ## 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. ## 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. ## 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;
}
}
}```

6. ## re: Request of code for Problems and assignments

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

Be sure to wrap all posted code in code tags.

7. ## Re: Methods with Parameters & Scanner Objects

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

Be sure to wrap all posted code in code tags.

8. ## Re: Text Processing

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

Be sure to wrap all posted code in code tags.

9. ## Re: Method with a return value & Conditional Execution

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

Be sure to wrap all posted code in code tags.

10. ## Re: Find the mistakes java exercise

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

[code]
[/code]

to get highlighting and preserve formatting.

11. ## 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. ## 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.

13. ## Re: Find the mistakes java exercise

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

14. ## re: Request of code for Problems and assignments

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

15. ## Re: Find the mistakes java exercise

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.

17. ## 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. ## 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.