meljun cortes itc 18

Upload: meljun-cortes-mbampa

Post on 02-Apr-2018

237 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 MELJUN CORTES ITC 18

    1/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    FIRST PRELIMINARY PERIOD

    GRADED EXERCISE #1

    Using BufferedReader/JOptionPane Class and Simple Formula Creations

    Duration: 1 week

    1. Write a JAVA program that will input Employee Name, Rate per hour, No. 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

    2. Create a JAVA program that will input a student name, course, student grade in quiz,

    seatwork, laboratory exercises, assignment and prelim exam. Compute and output the PrelimGrade.

    Prelim Grade = Quiz * 25% + Seatwork * 10% + lab. Exercise * 20% +

    Assignment * 5% + Prelim Exam * 40%

    3. Create a JAVA program that will input a value of measure in inches and output its equivalent

    in measure feet. Conversion Factor: 12 inches = 1 foot

    4. Create a JAVA program that will input an integer and output its square and cube;

    Example: 52 = 25 53 = 125

    Input an integer: 5 The square of a 5 is 25

    The cube of 5 is 125

    5. Create a JAVA program that will input the following data: Employee Number, Employee

    LastName, Employee FirstName, Rate per hour, Number of Hours Worked. Compute and

    ouput the Gross Pay, SSS Deduction, Tax Withhold, Total Deduction, Net PayGross Pay = No. of hrs worked * rate per hour.

    SSS Deduction = 5% of Gross Pay

    Tax Withhold = 10% of Gross Pay

    Total Deduction = SSS Deduction + Tax WithholdNet Pay = Gross Pay Total Deductions

    Page 1 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    2/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    GRADED EXERCISE #2

    Conditional Statements: If Else and Switch Case

    Duration: 1 week

    1. Write a JAVA program that will input a number andevaluate if the number is a Positive or 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 students 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.5092 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 Write a JAVA program that will input a password and test if

    the password is correct and display the message Password Accepted otherwise, displayInvalid Password.

    (Note: Password is JRU or jru)

    4 Write a JAVA program that will input a year code and output

    year level.

    Input => Year Code Output => Year Level1 First Year next line Freshmen

    2 Second Year next line Sophomore

    3 Third Year next line Junior4 Fourth Year next line Senior

    Note: Using if..else statement and year code is in character type.

    5 Using switchcase statement of #4.

    Page 2 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    3/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    GRADED EXERCISE #3Conditional Statements: If Else and Switch Case

    Duration: 1 week

    1. Write a JAVA program that will input the following data: Student Name, Average, Tuition Fee and

    output Total Tuition Fee.

    Formula: Total Tuition Fee = Tuition Fee Discount

    If average is: 95 100 100% discount

    90 94 25%

    85 89 10%84 and below no discount

    2 Write a JAVA program that will input Employee Name, Rate per

    hour, No. 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

    3. Write a JAVA program that will input a users choice based on the table below:

    Choice Input the following Compute & Output

    C for Circle Radius of a Circle Area = r2

    S for Square Side of Square Area = s2

    R for Rectangle Length & Width of a Rectangle Area = lw

    T for Triangle Base & Height of a Triangle Area = 1/2 bh

    4. Write a JAVA program that will compute for the net income of a particular employee. You have to

    accept name, position, and number of days worked. The position has three categories: ifManager,

    rate per day is P500; ifSupervisor, P400; ifEmployee, P300. Then after accepting the rate per day,

    compute gross = rate per day * no. of days worked, compute for the bonus, if gross is >= 8000,bonus = 1000; if gross>= 5000, bonus = 750; if gross >= 3000, bonus = 500; if less, bonus = 0;

    compute for the deductions: SSS is always 10% of gross; Medicare is always P100; and TAX, if

    gross >= 7000, tax = 15% of gross; if gross >= 4000, tax = 10% of gross, if gross >=2000, tax = 5%

    of gross. Then, compute forNet Income = gross + bonus total deduction. Then, display the net

    income.

    Sample Output:

    Name: Richard

    Manager Supervisor Employee

    Position: s

    Rate: 400

    No. of Days Worked: 15 Gross: 6000 Bonus: 750 Deductions:

    Tax: 600

    SSS: 600

    Medicare: 100Total Deduction: 1300

    Net Income: 5450

    Page 3 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    4/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    GRADED EXERCISE #4

    Looping Statements

    Duration: 2 weeks

    1. Write a JAVA program that will generate/output the following numbers.1, 2, 4, 7, 11, 16, 32, 39, 47, 56, 66

    2. Write a JAVA program that will input 10 scores and output the Highest and Lowest score.

    3. Write a JAVA program that will input the base and power and display the result:

    Example:

    Base is 4 Power is 2 the answer is 16 42 = 16Base is 2 Power is 5 the answer is 32 25 = 32

    Base is 0 Power is any no. the answer is 0 08 = 0

    Base is any no. Power is 0 the answer is 1 70 = 1Base is 0 Power is 0 the answer is Indeterminate i.e.: 00 = Indeterminate

    (Note: Math.pow( ) method is not allowed)

    4. Write a JAVA program that will input an integer number, and then will output the sum of all

    inputted numbers. The program will stop in accepting inputs if the user entered 0 (zero).Sample run #1: Sample run #2:

    5. Write a JAVA program that will generate the given output:

    Sample run #1: Sample run #2:

    Page 4 of 13

    Enter a number: 10Enter a number: 25

    Enter a number: 0

    Sum: 35

    Enter a number: 7Enter a number: 13

    Enter a number: 5Enter a number: 0

    Sum: 25

    Enter number of times: 3

    Number (1) : 10Number (2) : 5

    Number (3) : 2

    Difference: 3

    Product: 100

    Enter number of times: 5Number (1) : 8

    Number (2) : 4

    Number (3) : 2Number (4) : 3

    Number (5) : 0

    Difference: -1Product: 0

  • 7/27/2019 MELJUN CORTES ITC 18

    5/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    MIDTERM PERIOD

    GRADED EXERCISE #5

    Java Array: Single Dimensional

    Duration: 1 week

    1. Write a JAVA program that will input 10 scores and output the Highest and Lowest score. (USE

    ARRAY)

    2. Write a JAVA program that will generate the given output. A program that prints histogram.

    (USE ARRAY)

    Required Output:Elements Value Histogram

    0 10 * * * * * * * * * *

    1 3 * * *

    2 6 * * * * * *3 18 * * * * * * * * * * * * * * * * * *

    4 11 * * * * * * * * * * *5 1 *

    3. Input 5 integer values for arrayOne and 5 integer values for arrayTwo. Write a JAVA program

    that would merges two ordered list of integers into a single ordered list object of integers. Mergethe two arrays and sort.

    Example:

    arrayOne = 5, 9, 3, 0, 2 arrayTwo = 7, 1, 8, 6, 4

    Merged Array = 5, 9, 3, 0, 2, 7, 1, 8, 6, 4 Sorted Array: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

    Page 5 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    6/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    GRADED EXERCISE #6

    Java Array: Multi-Dimensional

    Duration: 2 weeks

    1. Declare two (2) dimensional arrays to store a name and grade. The program will not stop in

    accepting array elements until the user entered N.Sample Run:

    Enter name: Richard

    Enter grade: 100

    Add new record (Y/N) ? : Y

    Enter name: Mengvi

    Enter grade: 80

    Add new record (Y/N) ? : Y

    Enter name: Noli

    Enter grade: 70

    Add new record (Y/N) ? : N

    2. Write a JAVA program using array that will prompt the user with MENU options i.e., A. Search

    Record and B. Product Summary. (Note: Use multi-dimensional array to declare product records)

    Product Code Product Description Unit Price Quantity Sold

    C001 DVD-R 10.00 50

    C002 CD-RW 5.00 100

    C003 DVD-RW 20.00 10

    Sample Output: If A: Search Product

    If B: Product Summary

    Page 6 of 13

    GRADE SUMMARY REPORT

    Name Grade Remarks

    Richard 100 Passed

    Mengvi 80 Passed

    Noli 70 Failed

    Total Passed: 2

    Total Failed: 1

    - MENU -

    A. Search Product

    B. Product Summary

    ---------------------------------

    Enter choice: A

    Product Code Product Description Unit Price Quantity Sold Amount

    09-001 Raine Dessirei 10.00 50 50009-002 Railynne Dessirei 5.00 100 500

    09-003 Railee Darrel 20.00 10 200

    TOTAL AMOUNT: 1,200.00

    Enter Product Code: C003

    Product: DVD-RW

    Unit Price: 20.00Quantity Sold: 10Amount: 200.00

    Make a necessary prompt for invalid product code

    Format Total Amount (see sample output)

  • 7/27/2019 MELJUN CORTES ITC 18

    7/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    GRADED EXERCISE #7

    Methods

    Duration: 2 weeks

    1. Write a method multiplethat determines for a pair of integers whether the second integer is a multiple

    of the first. The method should take two integer arguments and return true if the second is a multiple

    of the first, false otherwise.

    Example #1:

    Enter first argument: 8

    Enter second argument: 2

    2 is a multiple of 8

    Example #2:Enter first argument: 20

    Enter second argument: 33 is not a multiple of 20

    2. Write a method prime_composite that determines if the value entered is a Prime Number or a

    Composite Number.

    Prime number is a number with factor 1 and itself.

    Example: 2, 3, 5, 7, 11, ., etc.

    Composite number is a number with more than 2 factors

    Example: 4, 6, 8, 9, 10, 12, 14, 15.., etc

    Example #1:

    Enter a number: 1111 is a prime number

    Example #2:

    Enter a number: 2525 is a composite number

    3. Write a method squareRoot that take single integer argument and returns the square roof of the

    inputted perfect square. (Note: built-in method is not allowed)

    Example #1:

    Enter a perfect square number: 100

    Square root of 100 is 10

    Example #2:

    Enter a perfect square number: 8

    8 is not a perfect square number

    Page 7 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    8/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    FINAL TERM PERIOD

    GRADED EXERCISE #8

    Arrays, Methods and Data Structures

    Duration: 1 week

    1. Declare a method to input 5 elements of arrayA, Declare a method to input 5 elements of

    arrayB. Call method mergeArray to merge elements of arrayA and arrayB. Create your own

    method sortArray to sort merged arrays in ascending order (Note: java.util package is not

    allowed and mergeArray and sortArray methods are to be called in the main method)

    2. Write a JAVA program that would input a string and display the total number of vowels and total

    number of consonants. (Note: use separate methods in getting the total vowels and

    consonants)Example:

    Input a string: beautiful

    Total Vowels: 5Total Consonants: 4

    3. Write a JAVA program using array that would input a string and uses a stack object and output

    its reverse order. Then, determine if the inputted string is a Palindrome or not; (i.e., the

    string is spelled identically backwards and forwards). The program should ignore spaces and

    punctuation.

    Example:Enter a string: wonderful Enter a string: radar

    The reverse: lufrednow The reverse: radar

    Not Palindrome Palindrome

    Page 8 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    9/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    GRADED EXERCISE #9

    Arrays, Methods and Data Structures

    Duration: 1 week

    1. Write a JAVA program using array to generate the given output below one at a time:

    (Application of Stack: last-in-first-out) (Application of Queue: first-in-first-out)

    R I C H A R D G W A P O

    R I C H A R W A P OR I C H A A P O

    R I C H P O

    R I C OR I

    R

    2. Write a JAVA program that would input the string value and display the stack result

    under functionStack and queue result under functionQueue.

    Example:

    Input a string: JRU

    Stack result: Queue result:

    J R U J R UJ R R U

    J U

    3. Write a JAVA program that would generate the following output:a) R I Z A L b) J c) j o s e r i z a l

    I J O o s e r i z a

    Z J O S s e r i zA J O S E e r i

    L r

    Page 9 of 13

  • 7/27/2019 MELJUN CORTES ITC 18

    10/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    CASE STUDY

    Arrays, Methods and Data Structures

    Duration: 2 weeks

    Declare an array containing the following elements Account Number, Account Name,

    Balance and Pin Number.

    Account Table:

    Account Number Account Name Balance Pin Number

    0123-4567-8901 Roel Richard 5000.00 1111

    2345-6789-0123 Dorie Marie 0.00 2222

    3456-7890-1234 Railee Darrel 10000 3333

    4567-8901-2345 Railynne Dessirei 2500 4444

    5678-9012-3456 Raine Dessirei 10000 5555

    Output #1:

    Output #2: IfS (Start Transaction)

    Page 10 of 13

    RGBC

    Richard Gwapo Banking Corporation

    S -> Start Transaction

    Q -> Quit

    Enter your choice: ___

    RGBCRichard Gwapo Banking Corporation

    Enter your pin number:

    1111

    Q means will close the

    program.

    o Use the pin number

    listed on Pin Table)

    o If the pin number iscorrect will display Output #3,

    else will prompt the user toinput the correct pin number.

    Note: pin number can enter 3 timesonly, otherwise will display the

    message CAPTURED CARD.

    PLEASE CALL 143-44

  • 7/27/2019 MELJUN CORTES ITC 18

    11/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    Output #3: (Type of Transaction) for correct pin number

    Output #4: If B: (Balance Inquiry)

    Output #4: If W: (Withdrawal)

    In case that the user inquire again for his/her balance

    Page 11 of 13

    RGBCRichard Gwapo Banking Corporation

    Account #: 0123-4567-8901

    Account Name: Roel RichardBalance: 5000.00

    Press X to Exit

    RGBC

    Richard Gwapo Banking Corporation

    Select Type of Transaction

    B -> Balance InquiryW -> Withdrawal

    D -> Deposit

    C -> Cancel

    Enter transaction type: ___

    RGBC

    Richard Gwapo Banking Corporation

    Enter amount to be withdrawn

    1000

    Press X to Exit

    X means will go back to Output #3(Type of Transaction)

    Applied to all Output #4 sample

    output

    Withdrawn amount should

    not be lower than 100 pesos Make a necessary prompt

    for invalid amount.

    o Valid amount: 100,

    200, 1700 etc (100denomination)

    o Invalid amount:

    450, 10, 1000.25 etc.

    RGBC

    Richard Gwapo Banking Corporation

    Account #: 0123-4567-8901

    Account Name: Roel Richard

    Balance: 4000.00

    Press X to Exit

    The current balance is4000.00

  • 7/27/2019 MELJUN CORTES ITC 18

    12/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    Output #4: If D: (Deposit)

    In case that the user inquire again for his/her balance

    NOTE:

    o Administrator pin number is 0000

    o Administrator account can do the following

    View all customer information Add new customer

    Edit customer information

    Change customer pin number

    Output #5: Administrator Viewing Only

    Page 12 of 13

    RGBC

    Richard Gwapo Banking Corporation

    Enter amount to be deposited

    3275.99

    Press X to Exit

    Deposited amount should

    not be lower than 100 pesos

    Make a necessary promptfor invalid amount.

    RGBC

    Richard Gwapo Banking Corporation

    Account #: 0123-4567-8901

    Account Name: Roel Richard

    Balance: 7275.99

    Press X to Exit

    The current balance is

    7275.99

    Deposited amount should

    not be lower than 100 pesos

    Make a necessary promptfor invalid amount.

    RGBC

    Richard Gwapo Banking Corporation

    What would you like to do?

    ( V ) View Customer Information( A ) Add New Customer

    ( E ) Edit Customer Information

    ( C ) Change Customer Pin Number

    ( X ) Exit

    Enter your choice: ____

    Note:

    Pressing X will go

    back to Output #1

  • 7/27/2019 MELJUN CORTES ITC 18

    13/13

    JOSE RIZAL UNIVERSITY Computer Science Department

    ITC 18 Advanced Programming

    LABORATORY EXERCISES

    Page 13 of 13