Assignment Set Three

The contract grading system requirements for this assignment set are:

C REQUIREMENTS

Complete any ten activities from Item A through Item N

B REQUIREMENTS

Complete ten activities in total. From the ten activities, four of them have to be B level programs and one of the four programs have to be on the computer.

A REQUIREMENTS

Complete ten activities in total. One of them has to be an A level program on the computer and four other B level programs.

Bonus:

If you hand this assignment in ON TIME, you get one letter grade higher than indicated above. You can get an A+ by meeting the A requirements, which is averaged one letter grade higher than an A.

You also get four activities.

If you hand this assignment in SLIGHTLY LATE, you get four activity bonus. However, you don't get the one letter-grade bonus.

The dates for ON TIME and SLIGHTLY LATE will be announced in class when we discuss a few problems.

In this assignment set, the conventional grading system requires that you do Item T or U on the computer.

ITEM a.

The City of Taxonia bases its tax rates on the number of dependents and one's income.

The laws for tax rate are as follows:

1)    Any taxpayer earning more than 10,000 dollars pays 50% taxes

2)    Any taxpayer earning less than 10,000 dollars pays 30% taxes

3)    Any taxpayer having between 0 and 2 dependents pays 35%  taxes

4)    Any taxpayer having three or more dependents pays 15% taxes

5)    In the case of any conflict between the above rules, the rule giving the higher percentage
      applies.
Write a program that reads in for one taxpayer, the number of dependents and their income. This data should be read from the keyboard with nice prompts.

It should print out their tax rate and the amount of taxes owed.



ITEM b.

The City of Gingrichville bases its tax rates on the number of dependents and the taxpayer's income.

The laws for tax rate are as follows:

1)    Any taxpayer earning more than 10,000 dollars pays 50% taxes

2)    Any taxpayer earning less than 10,000 dollars pays 30% taxes

3)    Any taxpayer having between 0 and 2 dependents pays 35% taxes

4)    Any taxpayer three or more dependents pays 15% taxes

5)    In the case of any conflict between the above rules, the rule giving the lower percentage
      applies.
Write a program that reads in for one taxpayer, the number of dependents and their income. This data should be read from the keyboard with nice prompts.

It should print out their tax rate and the amount of taxes owed.



ITEM c.

The City of Clintonville bases its tax rates on the number of dependents and the taxpayer's income.

The laws for tax rate are as follows:

1)    Any taxpayer with only one dependent (themselves) pays 40% in  taxes

2)    Any taxpayer with two or three dependents pays 30% in taxes

3)    Any taxpayer with four or more dependents pays 25% in taxes

4)    Any taxpayer making less than $10,000.00 pays 10% in taxes

5)    Any taxpayer making between $10,000.00 and $30,000.00 pays 25%  in taxes

6)    Any taxpayer making moe than $30,000.00 pays 35% in taxes

7)    In the case of any conflict between the above rules, the rule giving the lower percentage
      applies.
Write a program that reads in for one taxpayer, the number of dependents and their income. This data should be read from the keyboard with nice prompts.

It should print out their tax rate and the amount of taxes owed.



ITEM d.

The City of Kempston bases its tax rates on the number of dependents and the taxpayer's income.

The laws for tax rate are as follows:

1)    Any taxpayer with only one dependent (themselves) pays 40% in  taxes

2)    Any taxpayer with two or three dependents pays 30% in taxes

3)    Any taxpayer with four or more dependents pays 25% in taxes

4)    Any taxpayer making less than $10,000.00 pays 10% in taxes

5)    Any taxpayer making between $10,000.00 and $30,000.00 pays 25%  in taxes

6)    Any taxpayer making moe than $30,000.00 pays 35% in taxes

7)    In the case of any conflict between the above rules, the rule giving the higher percentage
      applies.
Write a program that reads in for one taxpayer, the number of dependents and their income. This data should be read from the keyboard with nice prompts.

It should print out their tax rate and the amount of taxes owed.



ITEM e.

To compute a price after a discount, one uses the following formula:

FinalPrice = OriginalPrice - OriginalPrice * DiscountRate

The discount_rate must be expressed as a decimal number.

For example, suppose you have made some purchases totalling $100.00 at K-Mart. However, let's say you work there as a programmer, so you get a 20% employee discount.

The original price would be $100

The discount_rate would be 0.20

To figure the final price (what one would end up having to pay), one would compute:

100 - 100 * 0.20

which gives eighty dollars.

Discount Widget Wharehouse bases its discount schedule on the number of widgets bought and the total value of the order (prior to the discount being applied).

You should write in a program that will read in the total value of the widgets purchased and the number of widgets purchased. The information should be read from the keyboard with nice prompts. After the data is read, you should print out the discount percentage that applies and the amount of money that the person owes.

The rules are as follows:

1)    Customers purchasing from 1 to 5 widgets get no discount

2)    Customers purchasing from 6 to 10 widgets get a 10% discount

3)    Customers purchasing more than 11 widgets get a 15% discount.

4)    Customers purchasing between $500 and $1000 worth of widgets  get a 5% discount

5)    Customers purchasing > $1000 worth of widgets get a 12%  discount.

6)    In the event that any of the two rules above conflict, then the customer gets the higher
      discount percentage, saving them more money.


ITEM f.

Needless Markup Widget bases its discount schedule on the number of widgets bought and the total value of the order (prior to the discount being applied).

You should write in a program that will read in the total value of the widgets purchased and the number of widgets purchased. The information should be read from the keyboard with nice prompts. After the data is read, you should print out the discount percentage that applies and the amount of money that the person owes.

The rules are as follows:

1)    Customers purchasing from 1 to 5 widgets get no discount

2)    Customers purchasing from 6 to 10 widgets get a 10% discount

3)    Customers purchasing more than 11 widgets get a 15% discount.

4)    Customers purchasing between $500 and $1000 widgets get a 5%  discount

5)    Customers purchasing > $1000 widgets get a 12% discount.

6)    In the event that any of the two rules above conflict, then the customer gets the lower
      discount percentage--this firm is stingy.


ITEM g.

Wally World Widgets bases its discount schedule on the number of widgets bought and the total value of the order (prior to the discount being applied).

You should write in a program that will read in the total value of the widgets purchased and the number of widgets purchased. The information should be read from the keyboard with nice prompts. After the data is read, you should print out the discount percentage that applies and the amount of money that the person owes.

The rules are as follows:

1)    Customers purchasing from 1 to 5 widgets get no discount

2)    Customers purchasing from 6 to 10 widgets get a 10% discount

3)    Customers purchasing more than 11 widgets get a 15% discount.

4)    Customers purchasing between $500 and $1000 widgets get a 5%  discount

5)    Customers purchasing between $1000 and $2000 widgets get a 12%  discount.

6)    Customers purchasing more than $2000 worth of widgets get a  14% discount

7)    In the event that any of the two rules above conflict, then the customer gets the higher
      discount percentage, saving them more money.

8)    Customers purchasing more than eight widgets and purchasing at least $1776 worth of
      widgets get an 18% discount.

9)    Customers not purchasing at least $250.00 worth of widgets and purchasing less than
      three distinct widgets do not get any discount--no matter what any of the above rules say.
ITEM h.

The Blofeld Widget shop needs a program to help them compute the amount of money that customers should pay for their widgets.

The program will take as input

A.    The number of widgets they bought.

B.    The price of the widget

C.    The part number of the widget 
Your program should compute the raw price (by multiplying the number of widgets times the price).

Then the system should compute the discount percentage using the rules below.

Then your program should compute the total amount to be paid by the customer after the discount.

Your program should print out the part number of the widget, the original price, the discount rate, and the final price--all with nice prompts.

(Some students may not have encountered discounts in their previous education or job experience.)

To compute a price after a discount, one uses the following formula:

FinalPrice = OriginalPrice - OriginalPrice * DiscountRate

The discount_rate must be expressed as a decimal number.

For example, suppose you have made some purchases totalling $100.00 at K-Mart. However, let's say you work there as a programmer, so you get a 20% employee discount.

The original price would be $100

The discount_rate would be 0.20

To figure the final price (what one would end up having to pay), one would compute:

100 - 100 * 0.20

which gives eighty dollars.

Rules:

I.    Anyone ordering only 1 widget gets no discount.

II.   Anyone ordering over a thousand dollars worth of widgets gets a 10% discount.

III.  Anyone ordering 2 to 5 widgets gets a 5% discount if they are also ordering over $100
      worth of merchandise.

IV.   Anyone ordering 6 to 10 widgets gets a 8% discount, unless if they are ordering over
      $200 worth of merchanidise.  Then, they get a 12% discount.

V.    Anyone ordering 11 or more widgets gets 15% discount if they bought less than $200
      worth of merchandise.  They get a 20% discount if they bought $200 to $750 worth of
      merchandise.  They get a 30% discount if they ordered over $750 worth of merchandise.

VI.   If two or more of the above rules conflict, then the rule that gives the lower discount
      applies.
ITEM i.

In the problem A, you wrote a program for the Blofeld Widget company to compute the payment amount for their customers. After completing it, you were asked to write a program for the James Bond 007 Widget Company.

They need the exact same program, to read in the number of widgets and their price and they need the same outputs, the final price, discount rate, part number and original price.

They even use the exact same rules for computing the discount as Blofeld Widget Company--there is one important difference. Rule VI says.

VI.   If two or more of the above rules conflict, then the rule that gives the higher discount
      applies.
So write the program for the James Bond 007 widget company.

ITEM A.

The state of Taxotocetts has the following system for computing taxes. They base the tax owed as a percentage of total income. However, that percentage varies as a function of two factors:

a. the earned income

b. the unearned income

The earned income represents income earned with the sweat of one's brow. The unearned income are things such as interest, dividends, rent received from property one owns, etc.

Your program is to read in the amount of earned income, and the amount of unearned income. It should then compute the tax rate as per the rules below. Then your program should compute the amount of tax owed.

Rules:

I.      If an individual earned less than $10,000 of earned income and less than $5,000 of
        unearned income, they pay no tax.

II.     If an individual earned less than $10,000 of earned income and less than $10,000 of
        unearned income, they pay 5% tax.

III.    If an individual earned less than $20,000 of earned income, and less than $10,000
        earned income, they pay 10% tax.

IV.     If an individual earned less than $20,000 of unearned income, and no more than
        $50,000 of earned income, they pay 20% tax.

V.      If an individual earned less than $25,000 of earned income, and no more than $50,000
        of unearned income, they pay 30% tax.

VI.     If an individual earned less than $30,000 of earned income and no more than $50,000
        of unearned income, they pay 50% tax.

VII.    If an individual earned more than $50,000 of unearned income and more than $50,000
        of earned income, they pay 60% tax.

VIII.   Any individual whose tax situation is not covered by the above rules, pays 55% tax.

IX.     In the event that two of the above rules give differing numbers, the rule that give the
        lower tax rate applies.
ITEM B.

A large garment store decided to sell out all the 'out of fashion' items they have. To encourage sales, prices were reduced based on the cost of the item and quantity of that item in stock with them. If the cost of item is less than $5, and there is less than 100 in stock, the price reduction is 10%. If there is 100 to 250 in stock, the price reduction is 20%. If there is 250 to 500 in stock, the discount is 30%. If there is more than 500 in stock, then the price reduction is 40%. In the same way if the cost of item is between $5 and $20, the price reductions will be 12%, 25%, 35%, and 50%. If the cost is between $20 and $50, the price reductions are 15%, 30%, 40%, and 60%. For all items that cost more than $50, reduction will be 25% irrespective of the quantity in stock.

A. Develop a decision table, on paper, as shown.

B. Write a pascal program to read quantity in stock and price of the item before reduction and output the price of the item after reduction on the screen.

Decision table for problem 2:

ITEM C.

The post-office offers four classes of mails, first-class, second-class, third-class and fourth-class. Postage for each class is different and it also varies depending on weight of the parcel. If the parcel is less than 1 lb, first-class mail will cost $2, second class-mail will cost $1.75, third-class mail will cost $1.50 and fourth class mail will cost $1.25. For each additional lb, extra postage for first-class mail is $1.75, for second-class mail $1.55, for third-class mail 1.40 and $1.00 for fourth-class mail.

Develop a decision table that will show the postage for different classes of mail and for weights up to 4 lbs, in multiples of 1 lb.

Write a pascal program that will read in the class of mail and weight, and prints out postage in dollars. Test your program for different weights.

ITEM D.

Each student is identified by a nine-digit social security number. Each student can register for up to 21 credits hours each semester.

If a student registers for less than 12 credits hours, tuition per credit hour is $120.
If a student registers for more than 12 but less than 18 credits hours, the tuition for the credit hours beyound 12 is $80 per credit hour. But if the total tuition is less than $1200, the student will be charged $1200.

If a student registers for more than 18 credit hours, the tuition for the credit hours beyond 18 will be $60 per credit hour.

All students must pay an additional fee. The fee for in-state students is $100 per semester. For out-of-state students, the fee is $200, and for international students the fee is $400.

Develop a decision table with the above information. Make up your own social security numbers and credits. Write a pascal program to read in the students' social security numbers, number of credits and a code for whether they are an in-state, out-of-state or an international student. It should print out each student's total tuition, college fee and the total bill on the screen.

(You will have to declare the variable to contain the social security number to be a "longint". E. G. if your variable to contain the social security number is ss_no, you will have to include the line:

SS_NO : longint;

after the "begin" statement. The variable "ss_no" would not be declared an integer.

ITEM E.

A retailing company sends its purchasing officer to a city to purchase three items. The company gave the officer the following instructions:

If item 1 is available for less than $100, then buy 10. If it costs more than $100 but less than $115, buy 8. If it costs more than $115 but less than $120, then buy 5. If it costs more than $120, do not buy that item.

If item 2 is available for less than $500, then buy 12. If it costs more than $500 but less than $550, buy 9. If it costs more than $550 but less than $575, then buy 5. If it costs more than $575, buy 3.

If item 3 is available for less than $50, then buy 20. If it costs more than $50 but less than $52, buy 15. If it costs more than $52 but less than $55, then buy 12. If it costs more than $55, buy 9.

If the total cost of items 1 and 2 is less than $1100, buy 5 more of item 1.

If the total cost of all items is less than $8000, then buy 4 more of item 3.

Develop a decision table from the above data. Write a pascal program to read in item number and cost of item and advice the officer how many he should purchase.

ITEM F.

A mid-western marketing agency markets the products of a company in Illinois, Iowa and Missouri. The company has a manufacturing unit and a sales-executive in each state. The Illinois sales-executive goes on a vacation in March, June, and October. Missouri sales-executive goes on a vacation in April, May, and December. When Illinois or Missouri sales-executive is on a vacation, the Iowa sales-executive will take charge of the state whose sales-executive went on a vacation and he will move to that state. (He will return to his original location when the other executive returns from vacation.) But the Iowa sales-executive will go on a vacation during May, June, and July. When the Iowa executive is on a vacation, the Illinois executive will take charge of Iowa and will stay there. If any two executives are on a vacation the remaining executive will take care of all the three states and will stay in Iowa.

Each time the agency wants to place an order, they must address the right sales-executive in the right place.

The sales-executives are James Peterson for Illinois, Amy Greenburg for Iowa and Roger Nicolson for Missouri.

a. Develop a decision table. Note that the contents of the table will be the name of the sales-executive and his location.

b. Write a pascal program to display the name of the sales-executive and his location. The input to the program will be the state and the month in which the order is placed. You can use numbers to represent state names as in problem 1 or learn how to read in character strings.

ITEM G. Level B Assignment

A mid-western marketing agency markets the products of four different companies in Illinois, Iowa and Missouri. Each of these companies have a manufacturing unit and their own sales-executive in each state. All Illinois executives go on a vacation in March, June and October. All Missouri executives go on a vacation in April, May and December. When someone is on a vacation, the various Iowa executives will take additional charge of the state whose sales-executives went on vacation.

Each time the agency wants to place an order, they must address the sales-executive of the right company, in the right place. The people at the agency are utterly confused with all these company names and city names and the sales-executives they have to contact. Can you help them out by organizing all the information they have in a decision table?

The four companies are P, Q, R and S.

P has its plants at Chicago, Illinois, St.Louis, Missouri and Burlington, Iowa. The sales-executives are Ralph for Illinois, Peterson for Iowa and Gerald for Missouri.

Q has its plants at Bloomington, Illinois, Kansas City, Missouri and Desmoines, Iowa. The sales-executives are Greg for Illinois, Joseph for Missouri and Cindy for Iowa.

R has its plants at Springfield, Illinois, St.Louis, Missouri and Iowa City, Iowa. The sales executives are Larry for Illinois, Cathy for Missouri and Green for Iowa.

S has its plants at Peoria, Illinois, Columbia, Missouri, and Keokuk, Iowa. The sales-executives are Amy for Illinois, Kelli for Missouri and Steve for Iowa.

a. Develop a decision table. Note that the contents of the table will be the location of the plant and the name of the sales-executive.

b. Write a pascal program to display a location of the manufacturing plant and the its sales-executive in a state. The input to the program will be the company name, state and the month in which the order is placed. You can use letters to represent state names as in problem 1 or learn how to read in character strings.

ITEM H. Level B Assignment

Read in three numbers from the file NUMBERS.3

Determine whether the three numbers are arranged in sorted order (ascending) if we consider their absolute values. Remember that the absolute value is the number after the sign (if any) is removed. E. G., the absolute value of -3 is 3. The absolute value of 3 is 3.

Print out an appropriate message on the screen either way.

For example if the strings on the left correspond to various input files, then to the right of the arrow is your program's response.

'-2 4 -7' --> you would print out a yes they are sorted
'4 -7 9' --> you would print out a yes they are sorted
'-1 -3 2' --> you would print out a no they are not sorted
'1 3 2' --> you would print out a no they are not sorted

ITEM I. Level B Assignment

Read in two numbers from the file FIRST.TWO

Read in two numbers from the file SECOND.TWO

You should print out one of three different messages on the screen as appropriate:

     "Both numbers of first file are less than both numbers of the second file"

     "Both numbers of first file are greater than both numbers of the second file"

     "The numbers are interdigitated"  --> what you print out when neither of the
     above two statements are true.
Examples:

If FIRST.TWO contained '1 7' and SECOND.TWO contained '9 8', then you would print out: "Both numbers of first file are less than both numbers of the second file."

On the otherhand, if FIRST.TWO contained '2 5' and SECOND.TWO contained '1 -107', then you would print out: "Both numbers of first file are greater than both numbers of the second file."

Now, if FIRST.TWO contained '2 5' and SECOND.TWO contained '1 4', then you would print out: "The numbers are interdigitated."

ITEM J. Level B Assignment

Read in two numbers from the file ASS3M.ONE

(Refer to these as the first pair)

Read in two numbers from the file ASS3M.TWO

(Refer to these as the second pair)

Print out one of the following messages. If more than one message applies, then print out only one--the one that is most specific.

"The sum of the first pair is greater than the sum of the second pair."

"The sum of the first pair is greater than one number of the second pair."

"The sum of the first pair is greater than each of the numbers of the second pair individually."

"The sum of the first pair is less than either of the numbers of the second pair individually."

If none of the above messages apply, print out: "I have nothing to say to you!"

ITEM K. Level A Assignment

In Item ? of Assignment Set Two, you wrote a program to read in data describing two rectangles. You drew rectangle 1 in red and the other rectangle was to be drawn in blue.

You are to modify your program as follows:

Those parts of the rectangle 1 that are inside rectangle 2 are to be drawn in yellow.

Those parts of the rectangle 2 that are inside rectangle 1 are to be drawn in white.

Those parts of rectangle 1 that are not inside rectangle 2 are to remain in red and those parts of rectangle 2 that are not inside rectangle 1 are to be drawn in blue as before.

Be careful to consider all cases! Rectangle 1 may be completely outside rectangle 2, it may be completely inside rectangle 2 or rectangle 1 may completely contain rectangle 2.

ITEM L. Level A Assignment

Read in from the keyboard, the coordinates of four points on a quadrilateral. That is you should read in four pairs of x and y values, each representing points of the quadrilateral in a clockwise fashion. Use real numbers.

You should print out one of the following four messages as appropriate.

"These four points precisely determine a square."

"These four points determine a square within a 0.1% accuracy"

"These four points don't form a square."

You might find useful the information in Unit 3.6, which may or may not be covered in class.

ITEM M. Level A Assignment

I have attached a form used by the Georgia Board of Pardons and Paroles in computing the number of years a felon should serve. You should read in from CRIM.CAS the following:

A crime severity number which will be a number from one to seven.

Answers to questions A through H "Parole Success factors"

You should also read in the court imposed sentence and the statutory maximum. You should also read in the time already served. You should output the recommended months to serve and whether or not the person will be paroled this month and whether they should expect no discharge from sentence without parole.


ITEM W.        Level A Assignment 
This program is supposed to check whether a given point is inside or outside a rectangle or a triangle. Your program will read the coordinate, (xl,yl), and the required dimensions of a rectangle and the dimensions of the triangle from a file called rect.tri. It would calculate whether the point is in the rectangle then it would calculate if the point is inside the triangle.

If (xl,yl) = (3.5,2.5) and the rect.tri were to contain

1 1 { (1,1) = the origin }
3 2 { (3,2) = the base and the height of the triangle and the rectangle }

As we can see above, the base starts at 1, hence it stretches upto 4. This value is greater than 3.5. Similarly, the height starts at 1 and stretches upto 3. This value is greater than 2.5. Therefore, we conclude that the point lies inside the rectangle.

As far as the triangle is concerned, using the two-point formula for a straight line we can calculate the coordiantes and compare them with (xl,yl) to find out whether the point is above or below the line or the hypotenuse of the triangle. If it is below the hypotenuse then the point is inside the triangle and if it is above the hypotenuse then the point is outside the triangle.