Tutorial 4
Tutorial 4
Tutorial 4
Activity 1
Write a program in Java to print the Fibonacci series up to a given number (entered by user).
Fibonacci is a popular number series in which, starting from the 3rd number, the number is equal
to the sum of the previous two numbers. The first two numbers are 0 and 1.
Deliverable
Fibonacci.java
Activity 2
An Armstrong’s number is 3-digit number for which sum of cube of its digits are equal to itself.
For example, 371 is an Armstrong number because of 3*3*3 + 7*7*7 + 1*1*1 = 371). Write
Java program to find and print out all Armstrong’s numbers between 100 and 999.
Deliverable
AmstrongNumbers.java
Activity 3
Carry out the following tasks with an array:
Deliverable
ArrayPractice.java
Activity 4
Write a program that:
Deliverable
ReverseStringArray.java
Activity 5
Write a program that simulates a small phone book. An array is used to store a list of names and
another array is used to store the phone numbers that go with each name. For example, Michael
Myers’ phone number is 333-8000 and Ash Williams’ phone number is 333-2323.
This program allows the user to look up a phone number by entering the person’s name or part of
his name. The program does this searching function in a case-insensitive manner. The program
should display a suitable message if the name is not found in the phone book.
Sample output 1
Sample output 2
Deliverable
ArrayPhoneBook.java
Activity 6
(extra)
Write code that fills an array values with each set of numbers below.
a. 1 2 3 4 5 6 7 8 9 10
b. 0 2 4 6 8 10 12 14 16 18 20
c. 1 4 9 16 25 36 49 64 81 100
d. 0 0 0 0 0 0 0 0 0 0
e. 1 4 9 16 9 7 4 9 11
f. 0 1 0 1 0 1 0 1 0 1
g. 0 1 2 3 4 0 1 2 3 4
Deliverable
ArraySequences.java
Activity 7
(extra)
Write Java code for a loop that simultaneously computes both the maximum and minimum of an
array.
Deliverable
ArrayMinMax.java
Submission
Submit a zip file containing all Java programs to this tutorial’s submission box in the course
website on FIT Portal.