Computer
Engineering Department
Bilkent University
Assignment No. 7
March 14, 2002
Notes: 1. Please READ the assignment. 2. Always bring your textbook to the lab for reference
purposes. 3. Study the programs
before coming to the lab and try to solve them as much as possible, finish the
HTML assignment, see below, before coming to the lab. Keep them in your H drive so that it would be easy to access them
in the labs. You may also keep them in
diskette. 4. Your assistants may
slightly change the programs as you work on them.
More on programming structures and an introduction to web page creation using
HTML.
At the beginning of each program you must indicate your
name, date, and the purpose of the program.
Your programs must have proper indentation, and make sure that 1.
your variable names are meaningful, 2. your program has enough comments
and blank lines for readability. 3. Your programs must have an easy to
follow user interface, and for each printed number your program must provide
its explanation such as
summation of even numbers from 2 to
7: 12.
Program 1: Find the reverse of a number.
Examples: 1234 becomes 4321, 1200 becomes 21 (i.e., ignore the leading zeros).
Note that you can construct a number from its individual digits.
Hint: Initialize sum as 0, and execute the following in a loop for each
nextDigit: sum= 10 *sum + nextDigit.
Program 2: Check if a number is a palindrome.
Examples: 121, 123321 are palindromes.
Program 3: Write an integer in terms of product of powers
of primes.
Every integer can be written as product of powers of
primes, for example 2= 2, 13= 13, 18= 2 x 3 x 3 (21.32),
36= 2 x 2 x 3 x 3 x 3.
Program 4: Find summation.
Find the summation: 1 + ½ + 1/3 + ... + 1/10000
With two for loops.
First try
for(i= 1; i <= 10000; i++)
and then try
for(i= 10000; i >= 1; i--) // ß corrected on Sunday, March 17, ‘02
Explain why the values are different. Which one is the more accurate value? (Note that you have to use floating point
arithmetic.)
First read the accompanying
HTML handout and the related appendix of the textbook for an introduction to
HTML.
1.
The title of the document must be “Your Name ‘s– Home Page.”
2.
Change the background and foreground colours of the
document as you wish. The colours you
choose do not matter as long as your document is not unreadable.
3.
Find the Bilkent University logo from the web and place
it to the center of the very top of your document.
4.
Modify the Personal
Info and Educational Background according
to your personal info.
5.
Between the Personal
Info and Educational Background
sections, write two paragraphs about yourself.
The context is not crucial and you may copy and paste from your previous
assignments.
6.
List the courses you are taking this semester within the Course Information section. Make sure to add links to the homepage of
the courses, as in the “CS-101:Introduction to Java” item in the list.
7.
Populate the table in the Schedule section according to your real course schedule.
8.
Add a new section “Some
of my friends” that gives the names of at least three of your friends and
links to their web pages.
Make sure that your programs are all seen and
approved by your assistant. If they
have different instructions regarding grading please follow their instructions.