Explore BrainMass
Share

Solve for Reusable Code

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Scenario: Different programming languages exist in various libraries and on the Internet and using some of these functions and procedures, this can allow you to use these methods rather than having to write out the code from scratch on your own. However, some code needs some modification to fit into your program. Nevertheless, imagine that you find 3 sets of code that you can reuse and have an implementation of the code.

Implement reusable code such as functions and sub-procedures. Use effective communication techniques.

© BrainMass Inc. brainmass.com October 16, 2018, 7:52 pm ad1c9bdddf
https://brainmass.com/computer-science/programming-languages/solve-for-reusable-code-130063

Solution Preview

Here is a more specific task of this nature:

Program Name { //begin of program

Procedure TrackPayment {

if amount_received < billing_amount then
amount_owing = billing_amount - amount_received

if date_payment_received > thirty_days then
late_fee_amount = late_charge_rate * billing_amount

account_balance = account_balance + amount_owing + late_fee_amount

}

Procedure CalculateInvoice {

if client_type = regular then
billing_amount = regular_price
else
billing_amount = regular_price - (service_price * discount_rate)

billing_amount = billing_amount + account_balance
}

Procedure PrintInvoice {

print client_name
print client_mailing_address
print invoice_number ...

Solution Summary

This solution illustrates how reusable codes such as functions and sub-procedures can be utilized in replacement of having to compose your own code. An invoice.zip file is also provided with this solution.

$2.19
Similar Posting

Question about Reusable Code

You realize that the code you had created can be reused for many other purposes for future programs. You decide to create a library for your reusable code. Using the pseudocode for the program, you identify the aspects of the program that can be reusable and write/rewrite it so it can be reused. You rewrite your pseudocode to implement this reusable code.

This is my code, how would I rewrite it?

Program Name { //begin of program

Procedure TrackPayment {

if amount_received < billing_amount then
amount_owing = billing_amount - amount_received

if date_payment_received > thirty_days then
late_fee_amount = late_charge_rate * billing_amount

account_balance = account_balance + amount_owing + late_fee_amount

}

Procedure CalculateInvoice {

if client_type = regular then
billing_amount = regular_price
else
billing_amount = regular_price - (service_price * discount_rate)

billing_amount = billing_amount + account_balance
}

Procedure PrintInvoice {

print client_name
print client_mailing_address
print invoice_number
print invoice_date
print billing_date
print billing_amount
print billing_period
}

begin main ( ) {
do TrackPayment
do CalculateInvoice
do PrintInvoice
}

} //end of program

View Full Posting Details