I"m getting so frustrated about this java course because the professor teachers absolutely nothing. WHich is ironic since the first exam was insanely simple!! So can someone give me a hand for a few problems? THey are basic loop problems:
4.
Consider the sequence 3, 4, 5, 6, 7. The sequence starts at 3 and ends at 7. Write a method called firstToLast, which is passed two integer values, first and last. The method then prints the integer sequence from first to last in a column.
For example, firstToLast(3,7) should print:
3
4
5
6
7
You may assume that first < last always holds.
----------------------------------
public void firstToLast(int first, int last){
CODE HERE
}
5.
Write a method called backwardsByTwos, which is passed an integer value, k. The method then counts backwards by 2, printing in a column the positive integer sequence k, k-2, k-4, and so forth.
If k <= 0, the method should print nothing.
For example, backwardsByTwos(6) should print:
6
4
2
------------------------
public void backwardsByTwos(int k){
CODE HERE
}
---
PSA - This is not the Software - Applications, Programming and Games forum.
AnandTech Moderator
4.
Consider the sequence 3, 4, 5, 6, 7. The sequence starts at 3 and ends at 7. Write a method called firstToLast, which is passed two integer values, first and last. The method then prints the integer sequence from first to last in a column.
For example, firstToLast(3,7) should print:
3
4
5
6
7
You may assume that first < last always holds.
----------------------------------
public void firstToLast(int first, int last){
CODE HERE
}
5.
Write a method called backwardsByTwos, which is passed an integer value, k. The method then counts backwards by 2, printing in a column the positive integer sequence k, k-2, k-4, and so forth.
If k <= 0, the method should print nothing.
For example, backwardsByTwos(6) should print:
6
4
2
------------------------
public void backwardsByTwos(int k){
CODE HERE
}
---
PSA - This is not the Software - Applications, Programming and Games forum.
AnandTech Moderator
