Java Quiz 1 Laboratory Exercise

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

Lab Activity No.

1 (Quiz 1) (10 points)

Title of the Activity: Printing with use of Escape Characters

Objectives of the Activity:


Students should be able to:
 Write a source code, compile and run a program in Java.
 Create a class.
 Differentiate print vs println
 Use if escape characters

Target Course Outcome:


CO1 – Explain the OOP concepts and constructs.

Instructions:
1. Create a program that will display your full name, course and section, and the statement Hello World.
Enclosed the in Asterisk. (See image of the sample output).
2. You cannot use \n to generate a new line however you can use \t to generate a tab.
3. Save your file as FirstActivity.java
4. Take a snippet/screenshot of your output.
5. Upload your source code (.java) and snippet/screenshot in the Google Classroom.

Hint: You can use as many escape characters (\t only) as you want.
Laboratory Activity No. 2 (Quiz 1) (15 points)

Title of the Activity: Getting an input from the user

Objectives of the Activity:


Students should be able to:
 Write a source code, compile and run a program in Java.
 Create a class.
 Use the method readLine() or showInputDialog() to get a user input.
 Convert a String to a desired data type.
 Output a value of a variable.

Target Course Outcome:


CO1 – Explain the OOP concepts and constructs.

Instructions:
1. Create a program that will convert seconds into HOUR:MINUTES:SECONDS.
2. Name your class as SecondActivity.
3. See the sample Output.
4. Save your file as SecondActivity.java
5. Take screenshots of your sample output (at least 4), for the user input enter any value you desired.

SPECIFICATIONS

1 Hour = 3600 seconds


1 Minute = 60 seconds

1:35:10
1 is for hour, 35 is for minutes, 10 is for seconds

Hint: You can use either readLine() or showInputDialog() methods; Use mathematical operators to solve this
problem.

Sample output 1.
Enter your name: Ma. Melanie Cruz
Enter seconds: 3600

Hello there Ma. Melanie Cruz


You entered 3600 seconds
The converted time is 1:0:0

Sample output 2.
Enter your name: Maxeen
Enter seconds: 2333

Hello there Maxeen


You entered 2333 seconds
The converted time is 0:38:53

Sample output 3.
Enter your name: Fawziya
Enter seconds: 350

Hello there Fawziya


You entered 350 seconds
The converted time is 0:5:50

Sample output 4.
Enter your name: Jessie
Enter seconds: 30

Hello there Jessie


You entered 30 seconds
The converted time is 0:0:30
Laboratory Activity No. 3 (Quiz 1) (35 points)

Title of the Activity: Logic formulation with control statements

Objectives of the Activity:


Students should be able to:
 Write a source code, compile and run a program in Java.
 Create a class.
 Use any control statements.

Target Course Outcome:


CO2 – Demonstrate the ability to design, extend, enhance and implement classes based on a
problem specification.

Instructions:
6. Create a program that will compute for the salary of an Employee.
7. Name your class as ThirdActivity.
8. See the sample Output.
9. Save your file as ThirdActivity.java
10. Take screenshots of your sample output (at least 4), for the user input enter any value you desired.

SPECIFICATIONS

Job Rate

Network Engineer 1200 per hour


Software Engineer 800 per hour
Full Stack Developer 600 per hour
Technical Support 500 per hour

Gross salary = Rate * no. of hours present


Net salary = Gross Salary - (Gross salary * 12%)

Hint: You can use either readLine() or showInputDialog() methods; You can use any control statement you want (If
Else if Else, Cascading If, Switch).

Sample output 1.
Enter your name: Ma. Melanie Cruz

Menu

[1] Network Engineer


[2] Software Engineer
[3] Full Stack Developer
[4] Technical Support

Enter your job (choose a number from the menu): 3


Enter no. of hours present in work: 36

Hello Ma. Melanie Cruz!


Your job salary as a Full Stack Developer is 600 per hour.
Your gross salary for this week is 21600.
Your net salary for this week is 19008.

Sample output 2.
Enter your name: Fawziya

Menu
[1] Network Engineer
[2] Software Engineer
[3] Full Stack Developer
[4] Technical Support

Enter your job (choose a number from the menu): 1


Enter no. of hours present in work: 40

Hello Fawziya!
Your job salary as a Network Engineer is 1200 per hour.
Your gross salary for this week is 48000.
Your net salary for this week is 42240.

You might also like