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

Exercisesconditional

The document outlines a series of exercises for writing JAVA programs that utilize conditional control structures. The tasks include evaluating numbers, calculating student grades, determining leap years, computing quiz scores, validating passwords, identifying year levels based on codes, and calculating employee wages with overtime. Each exercise emphasizes the use of if...else statements and switch...case statements for decision-making in programming.

Uploaded by

julius.claour
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)
5 views

Exercisesconditional

The document outlines a series of exercises for writing JAVA programs that utilize conditional control structures. The tasks include evaluating numbers, calculating student grades, determining leap years, computing quiz scores, validating passwords, identifying year levels based on codes, and calculating employee wages with overtime. Each exercise emphasizes the use of if...else statements and switch...case statements for decision-making in programming.

Uploaded by

julius.claour
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/ 2

Exercises

Conditional Control Structures

1. Write a JAVA program that will input a number and evaluate if the number is
“Positive”, “Negative” or “Zero”. If the number is positive display the message
“POSITIVE NUMBER”, if negative “NEGATIVE NUMBER, and if zero display the
message “ZERO”.

2. Write a JAVA program that will input a student’s final grade from 50-100. Evaluate
the Final grade and display the Point Equivalent based on the table below. Indicate
also the remarks if it is “Passed” or “Failed”.

Final Grade Equivalent Final Grade Equivalent


98 – 100 1.00 83 – 85 2.25
95 – 97 1.25 80 – 82 2.50
92 – 94 1.50 77 – 79 2.75
89 – 91 1.75 75 – 76 3.00
86 – 88 2.00 74 & below 5.00 (FAILED)

3. By definition a leap year is any year that is divisible by 4. However if a year is a


century year it is only a leap year if it is divisible by 400. Write a JAVA program that
will input a year and determine if the year is leap year of not.

4. Write a JAVA program that will input five scores of a student in five quizzes. Output
the sum and average of five scores. Determine and display the highest and lowest
score.

5. Write a JAVA program that will input a password and test if the password is correct
and display the message “Password Accepted” otherwise, display “Invalid
Password”.
(Note: Password is “UCC” or “ucc”)

6. Write a JAVA program that will input a year code and output year level.

Input => Year Code Output => Year Level


1 “First Year” next line “Freshmen”
2 “Second Year” next line “Sophomore”
3 “Third Year” next line “Junior”
4 “Fourth Year” next line “Senior”
Note: Using if...else statement and year code is in character type.

7. Solve Exercise #6 using switch…case statement.

8. Write a JAVA program that will input a course code and output its equivalent course;
Input => Course Code Output => Course
A or a “Accounting”
B or b “Banking and Finance”
C or c “Computer Science”
D or d “Dentistry”
E or e “Engineering”
else “Invalid Course Code”
Note: Using if..else statement.

9. Solve Exercise #8 using switch…case statement.

10.Write a JAVA program that will input Employee Name, Rate per hour and Number of
hours worked and will compute the daily wage of an employee. If the number of hours
worked exceeds eight hours add 30% to each excess hours as overtime rate.
Formula: Daily Wage = Rate per hour * No. of hours worked + OT pay

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy