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

Labsheet 2

Uploaded by

devmith2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Labsheet 2

Uploaded by

devmith2005
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ICT 1411

Object Oriented Programming

Lab sheet – Conditional Statements

Write Java programs to do the following tasks.

1. Prints whether the user given number is odd or even.


2. Find maximum between two user given numbers.
3. Rewrite the program in question 2 using ternary operator.
4. Check whether a given number is positive, negative or equal to zero.
5. Find maximum between three user given numbers.
6. Read a student’s mark (0-100) and reports what grade is obtained. Grading criteria are
given below. Data validation is needed.

Mark Range Grade


80-100 Distinction
60-79 Honors
50-59 Merit
40-49 Pass
0-39 Fail
7. Get lengths of three sides of a triangle as input and prints whether the triangle is
equilateral, isosceles, or scalene.
8. Develop a basic ATM machine program that enables users to perform three main
operations: withdrawing money, checking their account balance, and depositing funds.
The program should present users with a menu to choose from these options:
Upon selecting an option (1, 2, 3 or 4), the program should prompt the user to enter the
necessary information or amount for the chosen operation. After each transaction, the
program should display the updated account balance.
• For "Withdraw Money" (option 1)
The user should input the amount to be withdrawn. Ensure that the program checks if
the account has sufficient funds and that it displays an appropriate message if there are
insufficient funds.
• For "Check Account Balance" (option 2)
The program should display the current balance.
• For "Deposit Funds" (option 3)
The user should input the amount to be deposited. And the updated balance should
be displayed.
• For "Exit" (option 4)
The program needs to be terminated.
9. Create a program that allows the user to convert temperatures between Celsius and
Fahrenheit. The program should provide a menu with the following options:

The user is allowed to choose one of the options by entering the corresponding number. For
option 1, the program should ask the user to input a temperature in Celsius and then display
the equivalent temperature in Fahrenheit. For option 2, the program should ask for a
temperature in Fahrenheit and display the equivalent temperature in Celsius. For option 3,
user should be able to exit from the program.

Formula:
9
C = 𝑐 + 32
5

K = C + 273

10. Prints whether the user given character is a vowel or a consonant.

You might also like