Lunes, Enero 7, 2019

Methods - Activities 7-9

7. Select an Area to Perform

    Menu
    C. Circle
    R. Rectangle
    S. Square
    T. Triangle
    X. eXit
    Select [CRSTX] only:

   Methods: main - calls method menu
                   menu - displays the menu selection
                               allows the user to select an area to perform and redisplays the menu until 'X' is                                     selected, other characters would result to 'Invalid choice' output
                   circle - input the value of the radius
                                compute the area of the circle
                   rectangle - input the value of the length and width
                                     compute the area of the rectangle
                   square - input the value of the side
                                 compute the area of the square
                   triangle - input the value of the base and height
                                   compute the area of the triangle
                   result -  displays the result of the selected area


    Test Data:   Area        input value       output
                          C          r = 5                  78.54
                          R          l = 5, w = 3       15.0
                          S           s = 4                 16.0
                          T           b = 3, h = 5        7.5
                          A                                    Invalid choice

    Additional Requirement: Once the program is running, implement a looping process for methods circle, rectangle, square, and triangle to accept positive number/s only.


8. Implement a looping process for the inputs on prelim exam score and 5 quiz scores where the allowed entries range from 50 to 100 only. 

    Methods: main - input student name, prelim exam score   
                      quiz - input 5 quiz scores
                      average quiz - compute the average quiz
                      prelim grade - compute the prelim grade
                      remarks - based on the prelim grade, determine if 'Passed' or 'Failed'
                      output - display student name, prelim grade, remarks

     where: prelim grade = 60% of the average quiz + 40% of prelim exam score

      table:  prelim grade       remarks
                 0 - 74                  Failed
                75 - 100               Passed


     Test Data 1: Input: name = Ana
                                 prelim exam score = 100
                                 5 quiz scores = 100, 100, 100, 100, 100
             
                      Output: name = Ana
                                   prelim grade = 100.0
                                   remarks = Passed

     Test Data 2: Input: name = Ben
                                 prelim exam score = 50
                                 5 quiz scores = 50, 50, 50, 50, 50
             
                      Output: name = Ben
                                   prelim grade = 50.0
                                   remarks = Failed

     Test Data 3: Input: name = Cherry
                                 prelim exam score = 90
                                 5 quiz scores = 90, 100, 50, 70, 80
             
                      Output: name = Cherry
                                   prelim grade = 82.8
                                   remarks = Passed


     Test Data 4: Input: name = Dan
                                 prelim exam score = 0 -> invalid, allowed value is 50-100 only
                                 prelim exam score = 500 -> invalid, allowed value is 50-100 only
                                 prelim exam score = 80
                                 5 quiz scores = 80
                                                          100
                                                          0 -> invalid, allowed value is 50-100 only
                                                          50
                                                          100
                                                          80
             
                      Output: name = Dan
                                   prelim grade = 81.2
                                   remarks = Passed

Additional Requirement: Ask the user to TRY AGAIN [Y/N]

9.  input: employee name, employee code, number of days worked
               *allowed employee code is CPR, other characters are invalid
               *number of days work is from 0-13 only, all other numbers are invalid
     output:  employee name, gross pay, sss, tax, total deduction, net pay

     where: gross pay = rate per day * number of days worked
                 sss = 10% of gross pay
                 tax = 15% of gross pay
                 total deduction = sss + tax
                 net pay = gross pay - total deduction

     table:  employee code      rate per day
                        C                       500.0
                        P                        520.0
                        R                        550.0

    methods: main - calls method employee
                    employee - accepts all input requirements
                    rate - determines the rate per day
                    gross pay - computes the gross pay
                    sss - computes the sss
                    tax - computes the tax
                    total deduction - computes the total deduction
                    net pay - computes the net pay
                    output - displays all output requirements

    Test Data1: input: employee name = David
                                  employee code = C
                                  number of days worked = 10

                       output: employee name = David
                                    gross pay = 5000.0
                                    sss = 500.0
                                    tax = 750.0
                                    total deduction = 1250.0
                                    net pay = 3750.0

    Test Data2: input: employee name = Emma
                                  employee code = P
                                  number of days worked = 12

                       output: employee name = Emma
                                    gross pay = 6240.0
                                    sss = 624.0
                                    tax = 936.0
                                    total deduction = 1560.0
                                    net pay = 4680.0

    Test Data3: input: employee name = France
                                  employee code = R
                                  number of days worked = 12

                       output: employee name = France
                                    gross pay = 6600.0
                                    sss = 660.0
                                    tax = 990.0
                                    total deduction = 1650.0
                                    net pay = 4950.0

Additional Requirement: Ask the user to TRY AGAIN [Y/N]

Walang komento:

Mag-post ng isang Komento

Activity #17 - One-Dimensional Array

Place all codes under the method main. 1. Input 5 numbers and satisfy the ff:     a) sum of all input numbers     b) count of odd and ev...