HTW Berlin Fachbereich 4 Internationaler Studiengang Internationale Medieninformatik (Bachelor) Info 1: Informatik I Winter Term 2022/23 |
Laboratory 4 : A
Better Notebook
|
Pre-lab
This week's lab work is intended help you practice using loops.
Please bring these exercises printed out or written out with you to lab. Please have your name on your page.
P1. Write a loop on paper that prints out all multiples of 5 between 10 and 95.
P2. Write a method called sumBetween that adds up all numbers between two numbers, a and b, that are passed into the method as parameters. Include a but not b in the sum.
P3. Assume you have a collection of students called imi1. The Student class has a method getFirstName and a method getSurname. Write a loop that prints out all students in the collection with the last name first, then a comma, then a blank, and then the first name, each on a line by itself.
P4. Write a method isPrime that uses a while loop to test if a number given in a parameter is prime or not. A number is prime when it is divisible with a remainder of 0 only by 1 and itself.
Lab assignments are due before your next lab at 22.00. They may, of course, be turned in earlier. You hand them in by preparing the report in PDF and submitting it to Moodle.
Assignment
A Better Notebook
java.util.ArrayList
to find out how to do this. Writeup
Submit your writeup as your post-lab to the Moodle area.