Relationship rescue workbook excersices pdf free download






















Download Here. The free version of the Think CBT Workbook is presented as a static PDF, so that you can read the document on your device and print worksheets to complete by hand. In return for a free copy of the workbook, please help us to promote best practice in CBT by sharing this page or linking back to your website or social media profile. Download a copy. Other Therapies. The middle value can be found by computing the sum of all three values, and then subtracting the minimum value and the maximum value.

Day old bread is discounted by 60 percent. Write a program that begins by reading the number of loaves of day old bread being purchased from the user. Then your program should display the regular price for the bread, the discount because it is a day old, and the total price. All of the values should be displayed using two decimal places, and the decimal points in all of the numbers should be aligned when reasonable values are entered by the user.

If Statement Exercises 2 The programming constructs that you used to solve the exercises in the previous chapter will continue to be useful as you tackle these problems. In addition, the exercises in this chapter will require you to use decision making constructs so that your programs can handle a variety of different situations that might arise.

Solved—13 Lines Write a program that reads an integer from the user. Then your program should display a message indicating whether the integer is even or odd. Exercise Dog Years 22 Lines It is commonly said that one human year is equivalent to 7 dog years.

However this simple conversion fails to recognize that dogs reach adulthood in approximately two years. As a result, some people believe that it is better to count each of the first two human years as Ensure that your program works correctly for conversions of less than two human years and for conversions of two or more human years.

Your program should display an appropriate error message if the user enters a negative number. Exercise Vowel or Consonant Solved—16 Lines In this exercise you will create a program that reads a letter of the alphabet from the user. If the user enters a, e, i, o or u then your program should display a message indicating that the entered letter is a vowel.

If the user enters y then your program should display a message indicating that sometimes y is a vowel, and sometimes y is a consonant. Otherwise your program should display a message indicating that the letter is a consonant.

Exercise Name that Shape Solved—31 Lines Write a program that determines the name of a shape from its number of sides. Read the number of sides from the user and then report the appropriate name as part of a meaningful message. Your program should support shapes with anywhere from 3 up to and including 10 sides. If a number of sides outside of this range is entered then your program should display an appropriate error message. In this exercise you will create a program that reads the name of a month from the user as a string.

Then your program should display the number of days in that month. Exercise Sound Levels 30 Lines The following table lists the sound level in decibels for several common noises. If the user enters a decibel level that matches one of the noises in the table then your program should display a message containing only that noise.

If the user enters a number of decibels between the noises listed then your program should display a message indicating which noises the level is between. Ensure that your program also generates reasonable output for a value smaller than the quietest noise in the table, and for a value larger than the loudest noise in the table.

Exercise Name that Triangle Solved—20 Lines A triangle can be classified based on the lengths of its sides as equilateral, isosceles or scalene. All 3 sides of an equilateral triangle have the same length. An isosceles triangle has two sides that are the same length, and a third side that is a different length.

If all of the sides have different lengths then the triangle is scalene. Write a program that reads the lengths of 3 sides of a triangle from the user. Display a message indicating the type of the triangle. Exercise Note To Frequency Solved—39 Lines The following table lists an octave of music notes, beginning with middle C, along with their frequencies. Note Frequency Hz C4 Your program should support all of the notes listed previously. Once you have your program working correctly for the notes listed previously you should add support for all of the notes from C0 to C8.

While this could be done by adding many additional cases to your if statement, such a solution is cumbersome, inelegant and unacceptable for the purposes of this exercise. Instead, you should exploit the relationship between notes in adjacent octaves.

By using this relationship, you should be able to add support for the additional notes without adding additional cases to your if statement. Hint: To complete this exercise you will need to extract individual characters from the two-character note name so that you can work with the letter and the octave number separately. Once you have separated the parts, compute the frequency of the note in the fourth octave using the data in the table above. This will halve or double the frequency the correct number of times.

In this question you will write a program that reverses that process. Begin by reading a frequency from the user. If the frequency is within one Hertz of a value listed in the table in the previous question then report the name of the note. Otherwise report that the frequency does not correspond to a known note. In this exercise you only need to consider the notes listed in the table.

There is no need to consider notes from other octaves. The individuals that appear on banknotes in the United States are listed in Table 2. Write a program that begins by reading the denomination of a banknote from the user.

An appropriate error message should be displayed if no such note exists. While two dollar banknotes are rarely seen in circulation in the United States, they are legal tender that can be spent just like any other denomination. However, high denomination banknotes have not been printed since and were officially discontinued in As a result, we will not consider them in this exercise.

Exercise Date to Holiday Name 18 Lines Canada has three national holidays which fall on the same dates each year. Otherwise your program should indicate that the entered month and day do not correspond to a fixed-date holiday.

Canada has two additional national holidays, Good Friday and Labour Day, whose dates vary from year to year. There are also numerous provincial and territorial holidays, some of which have fixed dates, and some of which have variable dates. We will not consider any of these additional holidays in this exercise. The letter identifies the column, while the number identifies the row, as shown below: 8 7 6 5 4 3 2 1 a b c d e f g h Write a program that reads a position from the user.

Use an if statement to deter- mine if the column begins with a black square or a white square. Then use modular arithmetic to report the color of the square in that row. For example, if the user enters a1 then your program should report that the square is black. If the user enters d5 then your program should report that the square is white. Your program may assume that a valid position will always be entered. It does not need to perform any error checking. Exercise Season from Month and Day Solved—40 Lines The year is divided into four seasons: spring, summer, fall and winter.

The user will enter the name of the month as a string, followed by the day within the month as an integer. Then your program should display the season associated with the date that was entered.

One 12 year cycle is shown in the table below. The pattern repeats from there, with being another year of the dragon, and being another year of the hare. Your program should work correctly for any year greater than or equal to zero, not just the ones listed in the table. Exercise Richter Scale 30 Lines The following table contains earthquake magnitude ranges on the Richter scale and their descriptors: Magnitude Descriptor Less than 2.

For example, if the user enters 5. A quadratic function may have 0, 1 or 2 real roots. If the discriminant is negative then the quadratic equation does not have any real roots. If the discriminant is 0, then the equation has one real root. Otherwise the equation has two real roots, and the expression must be evaluated twice, once using a plus sign, and once using a minus sign, when computing the numerator.

Write a program that computes the real roots of a quadratic function. Your program should begin by prompting the user for the values of a, b and c. Then it should display a message indicating the number of real roots, along with the values of the real roots if any. Then your program should compute and display the equivalent number of grade points.

Exercise Grade Points to Letter Grade 47 Lines In the previous exercise you created a program that converts a letter grade into the equivalent number of grade points. In this exercise you will create a program that reverses the process and converts from a grade point value entered by the user to a letter grade.

Ensure that your program handles grade point values that fall between letter grades. These should be rounded to the closest letter grade. Exercise Assessing Employees Solved—28 Lines At a particular company, employees are rated at the end of each year. The rating scale begins at 0. The value awarded to an employee is either 0.

Values between 0. The meaning associated with each rating is shown in the following table. Rating Meaning 0. Your program should display an appropriate error message if an invalid rating is entered.

Exercise Wavelengths of Visible Light 38 Lines The wavelength of visible light ranges from to nanometers nm. Display an appropriate error message if the wavelength entered by the user is outside of the visible spectrum. Display the base charge, additional minutes charge if any , additional text message charge if any , the fee, tax and total bill amount. Only display the additional minute and text message charges if the user incurred costs in these categories.

Ensure that all of the charges are displayed using 2 decimal places. Exercise Is it a Leap Year? Solved—22 Lines Most years have days. However, the time required for the Earth to orbit the Sun is actually slightly more than that. As a result, an extra day, February 29, is included in some years to correct for this difference.

Such years are referred to as leap years. Write a program that reads a year from the user and displays a message indicating whether or not it is a leap year. Exercise Next Day 50 Lines Write a program that reads a date from the user and computes its immediate successor. For example, if the user enters values that represent then your program should display a message indicating that the day immediately after is If the user enters values that represent then the program should indicate that the next day is The date will be entered in numeric form with three separate input statements; one for the year, one for the month, and one for the day.

Ensure that your program works correctly for leap years. Exercise Is a License Plate Valid? Solved—28 Lines In a particular jurisdiction, older license plates consist of three uppercase letters followed by three numbers.

Write a program that begins by reading a string of characters from the user. Then your program should display a message indicating whether the characters are valid for an older style license plate or a newer style license plate. Your program should display an appropriate message if the string entered by the user is not valid for either style of license plate.

Of these spaces, 18 are black, 18 are red, and two are green. The green spaces are numbered 0 and The red spaces are numbered 1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30 32, 34 and The remaining integers between 1 and 36 are used to number the black spaces. Many different bets can be placed in roulette. Display the number that was selected and all of the bets that must be payed. For example, if 13 is selected then your program should display: The spin resulted in Loop Exercises 3 The exercises that appear in this chapter should all be completed using loops.

In some cases the exercise specifies what type of loop to use. In other cases you must make this decision yourself. Some of the exercises can be completed easily with both for loops and while loops. Other exercises are much better suited to one type of loop than the other. In addition, some of the exercises require multiple loops.

When multiple loops are involved, one loop might need to be nested inside the other. Carefully consider your choice of loops as you design your solution to each problem. Exercise Average 26 Lines In this exercise you will create a program that computes the average of a collection of values entered by the user.

The user will enter 0 as a sentinel value to indicate that no further values will be provided. Your program should display an appropriate error message if the first value entered by the user is 0. Hint: Because the 0 marks the end of the input it should not be included in the average.

Exercise Discount Table 18 Lines A particular retailer is having a 60 percent off sale on a variety of discontinued products. Ensure that the discount amounts and the new prices are rounded to 2 decimal places when they are displayed. Exercise Temperature Conversion Table 22 Lines Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit.

The table should include rows for all temperatures between 0 and degrees Celsius that are multiples of 10 degrees Celsius. Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit can be found on the internet. Now that pennies have been phased out retailers must adjust totals so that they are multiples of 5 cents when they are paid for with cash credit card and debit card transactions continue to be charged to the penny.

While retailers have some freedom in how they do this, most choose to round to the closest nickel. Write a program that reads prices from the user until a blank line is entered. Display the total cost of all the entered items on one line, followed by the amount due if the customer pays with cash on a second line.

The amount due for a cash payment should be rounded to the nearest nickel. One way to compute the cash payment amount is to begin by determining how many pennies would be needed to pay the total. Then compute the remainder when this number of pennies is divided by 5. Finally, adjust the total down if the remainder is less than 2. Otherwise adjust the total up. Exercise Compute the Perimeter of a Polygon Solved—42 Lines Write a program that computes the perimeter of a polygon.

Begin by reading the x and y values for the first point on the perimeter of the polygon from the user. Each time you read an additional coordinate you should compute the distance to the previous point and add it to the perimeter. When a blank line is entered for the x-coordinate your program should add the distance from the last point back to the first point to the perimeter. Then it should display the total perimeter.

Sample input and output is shown below, with user input shown in bold: Enter the x part of the coordinate: 0 Enter the y part of the coordinate: 0 Enter the x part of the coordinate: blank to quit : 1 Enter the y part of the coordinate: 0 Enter the x part of the coordinate: blank to quit : 0 Enter the y part of the coordinate: 1 Enter the x part of the coordinate: blank to quit : The perimeter of that polygon is 3.

In this exercise you will compute the grade point average of an arbitrary number of letter grades entered by the user. The user will enter a blank line to indicate that all of the grades have been provided. You may find your solution to Exercise 51 helpful when completing this exercise.

Your program does not need to do any error checking. It can assume that each value entered by the user will always be a valid letter grade or a blank line. Exercise Admission Price Solved—38 Lines A particular zoo determines the price of admission based on the age of the guest. Guests 2 years of age and less are admitted without charge. Create a program that begins by reading the ages of all of the guests in a group from the user, with one age entered on each line.

The user will enter a blank line to indicate that there are no more guests in the group. Then your program should display the admission cost for the group with an appropriate message. The cost should be displayed using two decimal places.

The basic idea is that an additional bit is transmitted after each group of 8 bits so that a single bit error in the transmission can be detected. Parity bits can be computed for either even parity or odd parity. If even parity is selected then the parity bit that is transmitted is chosen so that the total number of one bits transmitted 8 bits of data plus the parity bit is even. When odd parity is selected the parity bit is chosen so that the total number of one bits transmitted is odd.

Write a program that computes the parity bit for groups of 8 bits entered by the user using even parity. Your program should read strings containing 8 bits until the user enters a blank line.

After each string is entered by the user your program should display a clear message indicating whether the parity bit should be 0 or 1. Display an appropriate error message if the user enters something other than 8 bits. Hint: You should read the input from the user as a string. Then you can use the count method to help you determine the number of zeros and ones in the string.

Information about the count method is available online. The first approximation should make use of only the first term from the infinite series. As result, he developed what later became known as the Caesar Cipher. The idea behind this cipher is simple and as a result, it provides no protection against modern code breaking techniques. Each letter in the original message is shifted by 3 places. Non-letter characters are not modified by the cipher.

Write a program that implements a Caesar cipher. Allow the user to supply the message and the shift amount, and then display the shifted message. Ensure that your program encodes both uppercase and lowercase letters. Your program should also support negative shift values so that it can be used both to encode messages and decode messages. Exercise Is a String a Palindrome? Solved—23 Lines A string is a palindrome if it is identical forward and backward. Write a program that reads a string from the user and uses a loop to determines whether or not it is a palindrome.

Display the result, including a meaningful output message. Extend your solution to Exercise 72 so that it ignores spacing while determining whether or not a string is a palindrome.

For an additional challenge, extend your solution so that is also ignores punctuation marks and treats uppercase and lowercase letters as equivalent. Exercise Multiplication Table Solved—18 Lines In this exercise you will create a program that displays a multiplication table that shows the products of all combinations of integers from 1 times 1 up to and including 10 times Your multiplication table should include a row of labels across the top of it containing the numbers 1 through It should also include labels down the left side consisting of the numbers 1 through The expected output from the program is shown below: When completing this exercise you will probably find it helpful to be able to print out a value without moving down to the next line.

For example, print "A" will display the letter A and then move down to the next line. Exercise Greatest Common Divisor 35 Exercise Greatest Common Divisor Solved—17 Lines The greatest common divisor of two positive integers, n and m, is the largest number, d, which divides evenly into both n and m. There are several algorithms that can be used to solve this problem, including: Initialize d to the smaller of m and n.

While d does not evenly divide m or d does not evenly divide n do Decrease the value of d by 1 Report d as the greatest common divisor of n and m Write a program that reads two positive integers from the user and uses this algorithm to determine and report their greatest common divisor. Exercise Prime Factors 27 Lines The prime factorization of an integer, n, can be determined using the following steps: Initialize factor to two While factor is less than or equal to n do If n is evenly divisible by factor then Conclude that factor is a factor of n Divide n by factor using integer division Else Increase factor by one Write a program that reads an integer from the user.

If the value entered by the user is less than 2 then your program should display an appropriate error message. Otherwise your program should display the prime numbers that can be multiplied together to compute n, with one factor appearing on each line. Your program should begin by reading the binary number from the user as a string. Then it should compute the equivalent decimal number by processing each digit in the binary number. Finally, your program should display the equivalent decimal number with an appropriate message.

Exercise Decimal to Binary Solved—26 Lines Write a program that converts a decimal base 10 number to binary base 2. Read the decimal number from the user as an integer and then use the division algorithm shown below to perform the conversion. When the algorithm completes, result contains the binary representation of the number.

Display the result, along with an appropriate message. Let result be an empty string Let q represent the number to convert repeat Set r equal to the remainder when q is divided by 2 Convert r to a string and add it to the beginning of result Divide q by 2, discarding any remainder, and store the result back into q until q is 0 Exercise Maximum Integer Solved—34 Lines This exercise examines the process of identifying the maximum value in a collection of integers.

Each of the integers will be randomly selected from the numbers between 1 and The collection of integers may contain duplicate values, and some of the integers between 1 and may not be present. Take a moment and think about how you would handle this problem on paper. Many people would check each integer in sequence and ask themself if the number that they are currently considering is larger than the largest number that they have seen previously.

If it is, then they forget the previous maximum number and remember the current number as the new maximum number. This is a reasonable approach, and will result in the correct answer when the process is performed carefully. If you were performing this task, how many times would you expect to need to update the maximum value and remember a new number? Exercise Maximum Integer 37 While we can answer the question posed at the end of the previous paragraph using probability theory, we are going to explore it by simulating the situation.

Create a program that begins by selecting a random integer between 1 and Save this integer as the maximum number encountered so far. After the initial integer has been selected, generate 99 additional random integers between 1 and Check each integer as it is generated to see if it is larger than the maximum number encountered so far. If it is then your program should update the maximum number encountered and count the fact that you performed an update. Display each integer after you generate it.

Include a notation with those integers which represent a new maximum. After you have displayed integers your program should display the max- imum value encountered, along with the number of times the maximum value was updated during the process.

Partial output for the program is shown below, with… representing the remaining integers that your program will display. Run your program several times. Is the number of updates performed on the maximum value what you expected? In this exercise we will explore these questions by creating a program that simulates several series of coin flips.

The simulated coin should be fair, meaning that the probability of heads is equal to the probability of tails. Your program should flip simulated coins until either 3 consecutive heads of 3 consecutive tails occur. Ask each child to tell you something about kindness e.

Highlight to the class characteristics of a good and healthy friendship or relationship. As we have already learned, having positive relationships with our peers can make us feel good. In order to have positive peer relationships, we must first understand the basic characteristics of being a good friend. This worksheet will help you think about what happens to you when you drink or take drugs and the impact on your child.

Phil, Oprahs resident expert on human functioning, provides questions, exercises and self-tests that will enable couples in even the most troubled relationships to get their love lives back on track. And for those in solid relationships who would like to regain their spark, he reveals how to make that happen.

He shows readers exactly how to pinpoint problems in their relationships, and how to make sure that the changes they enact will truly last.



0コメント

  • 1000 / 1000