1. Write pseudocode instructions to carry out each of the following computational operations: a. Determine the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Write pseudocode instructions to carry out each of the following computational operations: a. Determine the area of a triangle given values for the base b and the height h. b. Compute the interest earned in 1 year given the starting account balance B and the annual interest rate I and assuming simple interest, that is, no compounding. Also determine the final balance at the end of the year. c. Determine the flying time between two cities given the mileage M between them and the average speed of the airplane 2. Write an algorithm that gets the price for item A plus the quantity purchased. The algorithm prints the total cost, including a 6% sales tax 3. Write an ifthen/else primitive to do each of the following operations: a. Compute and display the value x + y if the value of y is not 0. If y does have the value 0, then display the message 'Unable to perform the division. b. Compute the area and circumference of a circle given the radius r if the radius is greater than or equal to 1.0; otherwise, you should compute only the circumference. 4. Write an algorithm that uses a loop a. to input 10 pairs of numbers, where each pair represents the score of a football game with the Computer State University (CSU) score listed first, and b. for each pair of numbers, to determine whether CSU won or lost. After reading in these 10 pairs of values, print the won/lost/tie record of CSU. In addition, if this record is a perfect 10-0, then print the message "Congratulations on your undefeated season. Chapter 1 Challenge: One of the most important and widely used classes of algorithms in computer science is sorting, the process of putting a list of elements into a predefined order, usually numeric or alphabetic. There are many different sorting algorithms, and we will look at some of them in Chapter 3. One of the simplest sorting algorithms is called selection sort, and it can be implemented using the tools that you have learned in this chapter. It is also one of the easiest to understand as it mimics how we often sort collections of values when we must do so by hand. Assume that we are given a list named A, containing eight values that we want to sort into ascending order, from smallest to largest 23 A: Position 18 2 66 3 4 21 15 Part 2: Using Idle, create and edit the following program Programming Exercise 4 90 6 We first look for the largest value contained in positions 1-8 of list A. We can do this using something like the Find Largest algorithm that appears in Figure 2.14. In this case, the largest value is 90, and it appears in position 6. Because this is the largest value in list A, we swap it with the value in position 8 so that it is in its correct place at the back of the list. The list is now partially sorted from position 8 to position 8: A: 23 18 9 Position 1 2 32 66 3 21 5 21 5 4 6 32 We now search the array for the second largest value. Because we know that the largest value is contained in position 8, we need to search only positions 1-7 of list A to find the second largest value. In this case, the second largest value is 66, and it appears in position 3. We now swap the value in position 3 with the value in position 7 to get the second largest value into its correct location. This produces the following: A 23 18 32 Position 1 2 3 66 4 8 4 6 90 8 90 8 The list is now partially sorted from position 7 to position 8, with those two locations holding the two largest values. The next search goes from position 1 to position 6 of list A, this time trying to locate the third largest value, and we swap that value with the number in position 6. After repeating this process seven times, the list is completely sorted. (That is because if the last seven items are in their correct place, the item in position 1 must also be in its correct place.) Using the Find Largest algorithm shown in Figure 2.14 (which may have to be slightly modified) and the primitive pseudocode operations listed in Figure 2.9, implement the selection sort algorithm that we have just described. Assume that n, the size of the list, and the n-element list A are input to your algorithm. The output of your algorithm should be the sorted list. Write and test a Python script that, given a number of bytes, outputs the equivalent number of kilobytes, megabytes, gigabytes, and terabytes. Write and test a complementary script that, given a number of terabytes, outputs the equivalent number of GB, MB, KB, and bytes. 1. Write pseudocode instructions to carry out each of the following computational operations: a. Determine the area of a triangle given values for the base b and the height h. b. Compute the interest earned in 1 year given the starting account balance B and the annual interest rate I and assuming simple interest, that is, no compounding. Also determine the final balance at the end of the year. c. Determine the flying time between two cities given the mileage M between them and the average speed of the airplane 2. Write an algorithm that gets the price for item A plus the quantity purchased. The algorithm prints the total cost, including a 6% sales tax 3. Write an ifthen/else primitive to do each of the following operations: a. Compute and display the value x + y if the value of y is not 0. If y does have the value 0, then display the message 'Unable to perform the division. b. Compute the area and circumference of a circle given the radius r if the radius is greater than or equal to 1.0; otherwise, you should compute only the circumference. 4. Write an algorithm that uses a loop a. to input 10 pairs of numbers, where each pair represents the score of a football game with the Computer State University (CSU) score listed first, and b. for each pair of numbers, to determine whether CSU won or lost. After reading in these 10 pairs of values, print the won/lost/tie record of CSU. In addition, if this record is a perfect 10-0, then print the message "Congratulations on your undefeated season. Chapter 1 Challenge: One of the most important and widely used classes of algorithms in computer science is sorting, the process of putting a list of elements into a predefined order, usually numeric or alphabetic. There are many different sorting algorithms, and we will look at some of them in Chapter 3. One of the simplest sorting algorithms is called selection sort, and it can be implemented using the tools that you have learned in this chapter. It is also one of the easiest to understand as it mimics how we often sort collections of values when we must do so by hand. Assume that we are given a list named A, containing eight values that we want to sort into ascending order, from smallest to largest 23 A: Position 18 2 66 3 4 21 15 Part 2: Using Idle, create and edit the following program Programming Exercise 4 90 6 We first look for the largest value contained in positions 1-8 of list A. We can do this using something like the Find Largest algorithm that appears in Figure 2.14. In this case, the largest value is 90, and it appears in position 6. Because this is the largest value in list A, we swap it with the value in position 8 so that it is in its correct place at the back of the list. The list is now partially sorted from position 8 to position 8: A: 23 18 9 Position 1 2 32 66 3 21 5 21 5 4 6 32 We now search the array for the second largest value. Because we know that the largest value is contained in position 8, we need to search only positions 1-7 of list A to find the second largest value. In this case, the second largest value is 66, and it appears in position 3. We now swap the value in position 3 with the value in position 7 to get the second largest value into its correct location. This produces the following: A 23 18 32 Position 1 2 3 66 4 8 4 6 90 8 90 8 The list is now partially sorted from position 7 to position 8, with those two locations holding the two largest values. The next search goes from position 1 to position 6 of list A, this time trying to locate the third largest value, and we swap that value with the number in position 6. After repeating this process seven times, the list is completely sorted. (That is because if the last seven items are in their correct place, the item in position 1 must also be in its correct place.) Using the Find Largest algorithm shown in Figure 2.14 (which may have to be slightly modified) and the primitive pseudocode operations listed in Figure 2.9, implement the selection sort algorithm that we have just described. Assume that n, the size of the list, and the n-element list A are input to your algorithm. The output of your algorithm should be the sorted list. Write and test a Python script that, given a number of bytes, outputs the equivalent number of kilobytes, megabytes, gigabytes, and terabytes. Write and test a complementary script that, given a number of terabytes, outputs the equivalent number of GB, MB, KB, and bytes.
Expert Answer:
Answer rating: 100% (QA)
Lets start by addressing the pseudocode instructions for the given computational operations a Area of a Triangle Input base b height h Output area are... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
A company is considering buying a new truck or keeping their old truck.The cost of the new truck is $60,000.The cost of the old truck was $45,000.The company has $60,000 in the bank that they are...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
A database is to be made to store information about a catalogue of CDs. Information to be stored about each CD includes title, price, genre, and a list of tracks. Each CD will also have an artist,...
-
Walmart Stores, Inc. is sued about once every two hours every day of the year. These allegations range from falls on icy parking lots to injuries sustained in shoppers' stampedes to a murder with a...
-
Pique AG shows a balance of 241,140 in the Accounts Receivable account on December 31, 2022. The balance consists of the following. Installment accounts due in 2023...
-
What is meant by the concept litigation plan?
-
Wallowa Company is considering a long-term investment project called ZIP. ZIP will require an investment of $120,000. It will have a useful life of 4 years and no salvage value . Annual cash inflows...
-
5. (a) What are the conditions for a function of two variables f(x, y) to have a critical point? Give sufficient conditions in terms of the second derivatives at the critical points for classifying...
-
Reba Dixon is a fifth-grade school teacher who earned a salary of $38,000 in 2019. She is 45 years old and has been divorced for four years. She receives $1,200 of alimony payments each month from...
-
Which value below represents the largest value a byte can hold? 1 2 8 6 4 2 5 6 2 5 5
-
E. Chrissy's Vases is a boutique selling artisan vases. The boutique purchases several styles of vases from one source. The cost of the vases to the boutique is $10 each. All other costs for...
-
References: McLean, S. (2018). Exploring Interpersonal Communication (2nd ed) . VitalSource Bookshelf. vbk://9781453390429 Challenge : I have no idea how to argue with someone in a polite manner ...
-
The three partners of Hawkdale Contractors agree to liquidate their partnership on August 8th, 2021. At that point, the accounting records show the following balances: Cash $142,600 Inventory 402,900...
-
The units of an item available for sale during the year were as follows: Jan.1 Inventory 26 units at $400 per unit Feb. 19 Purchase 54 units at $460 per unit June 8 Purchase 63 units at $540 per unit...
-
1. Define "Risk management". 2. Differentiate between a risk averse entrepreneur and a risk seeking entrepreneur. 3. Give four categories of hazard-based risks and provide an example of each. 4....
-
What is "margin debt"? Why do selected market analysts believe that margin debt fuels bubbles in the equity market? What are the Fed's rules regarding traditional margin debt and how do they differ...
-
On October 1, 2021, Adoll Company acquired 2,600 shares of its $1 par value stock for $38 per share and held these shares in treasury. On March 1, 2023, Adoll resold all the treasury shares for $34...
-
Steve Jackson (age 51) is a single taxpayer living at 3215 Pacific Dr., Del Mar, CA 92014. His Social Security number is 465-88-9415. In 2012, Steve's earnings and income tax withholding as the...
-
Bill and Guilda each own 50 percent of the stock of Radiata Corporation, an S corporation. Guilda's basis in her stock is $25,000. On July 31, 2012, Bill sells his stock, with a basis of $40,000, to...
-
Greg died on July 1, 2012, and left Lea, his wife, a $50,000 life insurance policy which she elects to receive at $5,000 per year plus interest for 10 years. In the current year, Lea receives $6,200....
-
You are the senior partner of a large, local audit firm. In reviewing the work of a junior staff member on a compilation engagement for Greasemonkey's Delight Inc., a local autoparts store (in which...
-
You have been assigned to audit the accounts payable of Slamtastic, a small recording company specializing in alternative music. Following is a portion of their accounts payable journal for the month...
-
The chapter discussed three issues to consider when obtaining evidence using a sample-based audit procedure: a. The number of transactions or items to examine b. The actual transactions or items to...
Study smarter with the SolutionInn App