Instructor Lab Manual
OOP: Object Oriented
Programming
CS230 - IT232 - CS140 – IT401
College of Computing & Informatics
SAUDI ELECTRONIC UNIVERSITY
Page | 1
Page | 2
Week 6-7
Exercise 1:
Write a java program that ask the user to enter tow positive numbers. If the
user enter a negative number, then the program keep asking him\her to
renter a positive one. Finally, the program print the sum of the tow numbers.
Typical run of the program
Exercise 2:
Write a java program that ask the user to enter his\her grade. The grade
must be between 0 and 100, and then print if the user succeed or fail. To
succeed the grade must be greater then 60.
Typical run of the program
Page | 3
Exercise 3:
Write a java program, using the while loop, that:
- Ask the user to give a positive number less than 100.
- Print all the numbers from the given number to 200.
Typical run of the program
Exercise 4:
Write java program that ask the user to enter a number between 50 and 100
then print all the multiple of 5 from zero to the given number.
Typical run of the program
Exercise 5:
Write java program that ask the user to enter a number between 50 and 100
then print all the multiple of 5 from the given number to 200.
Typical run of the program
Page | 4
Exercise 6:
An old men wants to buy a new or an antique car. He wants that the age of
the car will be between 0 and 3 years or between 40 and 50 years.
Write a java program that asks the user to give a number that must be
between o and 3 or between 40 and 50. The program keeps asking the user
to give that number until getting a suitable one. Finally, depending on the
given number the program print "old car" or "new car".
Typical run of the program
Exercise 7:
Write a java program that asks the user to give a number between 1 and 7.
Use the "switch" keyword to print the corresponding day. For example, if the
user enters number 4, the program will print Wednesday.
Typical run of the program
Exercise 8:
Write a java program that act as a simple calculator using the switch
statement.
Typical run of the program
Page | 5