0% found this document useful (0 votes)
12 views

Lab Sheet 3

Uploaded by

devmith2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lab Sheet 3

Uploaded by

devmith2005
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ICT 1411

Object Oriented Programming

Lab sheet – Loops

Write Java programs to do the following tasks.

1. Print your name for 10 time using a while loop.


2. Print numbers from 1 to 10 using a for loop.
3. Print numbers from 20 to using a for loop.
4. Print all even numbers between 1 and 50.
5. Get ten student marks from the user until user enters a negative value.
6. Calculate total height of the ten plants given by the user.
7. Show the following menu repeatedly until user enters choice 3.

8. Calculate the fine for returning a library book late:


• For up to 5 days: $0.50 per day
• For 6 to 10 days: $1.00 per day
• For 11 to 30 days: $5.00 per day
• Beyond 30 days: $10.00 per day
9. The user should be able to calculate fines for multiple books until they choose to stop.
10. Print the following patterns using loops.
a) * * * * * b) * c) 1
* * * * * * * 2 2
* * * * * * * * 3 3 3
* * * * * * * * * 4 4 4 4
* * * * * * * * * * 5 5 5 5 5

d) 1 e) * * * * *
1 2 * * * *
1 2 3 * * *
1 2 3 4 * *
1 2 3 4 5 *

You might also like