Purchase Solution

Examples of Loops in C: While-Do, Do-Until and For-Loop

Not what you're looking for?

Ask Custom Question

NOTE: C coding is fine. Please explain the process.

Senario: For many years, your Uncle Frank has been running a small landscaping business. Through these years, he acquired many steady clients and knew most of them on a first name basis. Once a month, after completing the work for that day, he would calculate (on the spot) how much the client owed for the month with services rendered each week; he would collect the payment and write a receipt.

His clients were charged various prices. Some clients were given a 10% discount because they were old friends. Some clients were given a $10.00 discount per lawn because of the amount of their business (5 lawns or more). New clients just paid the regular advertised price of $35.00 per lawn.

Recently, your uncle has hired some additional help because he has been getting older and can't do all the work like he used to. These employees are good and do a great job on landscaping, but for some reason, they have a hard time collecting payments. Either they forget to get a payment or they quote the wrong amount to the client. Your uncle knows he has to find a solution to this problem quickly; otherwise, he may go bankrupt.

At the next family gathering, your uncle asked you if you knew of any solutions for this problem. Since you are in college and taking a computer course, you know that this problem could easily be solved with the use of a computer.

After discussing this with your uncle, you agree to set up a computer and create a program that would keep track of his clients. It would calculate the bills and print invoices that would be mailed to the clients. It will also keep track of the client payments when they were received.

When the clients received their invoices, they would have 30 days to send in their payment. When the payment was received, the program would update the account to reflect this payment, but if no payment was received, then this month's bill would be added to next month's bill plus a 5% late charge.

Purchase this Solution

Solution Summary

This solution provides the pseudocode in C.

Solution Preview

Below is a pseudocode in C.
//========================================

// Firs introduce a struct to represent a client, for instance:

static const int MAX_LEN = 100 ;
static const float PRICE = 35.00 ; // price per lawn
static const float DISCOUNT = 0.10 ; // discount amount for friends

struct CLIENT
{
char first_name [MAX_LEN+1] ;
char last_name [MAX_LEN+1] ;
int aob ; // amount of business; 5 lawns or more will get a $10.00 discount per lawn
int friend ; // 1 - friend, 0 - not friend; friends get 10% discount per lawn
float current_balance;// if no payment was received, this month's bill is added to next month's bill plus a 5% late charge
} ;

void CalculateBill (struct CLIENT* p) ;
void GenerateInvoice (struct CLIENT* p) ;

//======================================
// ...

Purchase this Solution


Free BrainMass Quizzes
Basic UNIX commands

Use this quiz to check your knowledge of a few common UNIX commands. The quiz covers some of the most essential UNIX commands and their basic usage. If you can pass this quiz then you are clearly on your way to becoming an effective UNIX command line user.

Basic Networking Questions

This quiz consists of some basic networking questions.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.