COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Methods RightTriangle.java RightTriangleWithLoop.java Geometry.java PayrollWithMethod.java PayrollWithMethodLoop.java Palindrome.java GlobalAndLocal.java Overloading.java Overloading2.java MathMethods.java and MathProgram.java CaesarCipher.java



PayrollWithMethodLoop Program


Description

This program is the enhanced version of the previous program.

In the main() method, it uses a loop to accept the user input and call the methods until the user chooses not to.

Associated Concepts:

Method

Global constants

Calling methods in a loop

Algorithm:

Define global constants so they are accessible by all methods in the program.

main method:

Declare local variables

do ... while loop:

    input data from the keyboard

    Call calculatePayroll method and pass arguments to get the weekly pay

    Call printPayroll method and pass arguments to print the payroll report

    Input "Yes" or "No" from the user to determine if the loop should continue to execute.

Write method definitions

Source Code



Sample Run




Video