Computer Science: An Overview (13th Edition) (What's New in Computer Science)
13th Edition
ISBN: 9780134875460
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 5.6, Problem 5QE
Explanation of Solution
“No”, the program to compute quotient is not correct. The program does not provide correct answer for the case when dividend is less than divisor...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program that calculates the equivalent resistance of a circuit. n electrical resistors with
resistance values R1, R2,.., Rn are said to be connected in parallel if the same voltage is applied
across each. Their equivalent resistance Reg is related to the values R1, R2, ...,
Rn by:
1
1
1
1
+
+...+
R R R,
R.
"eq
Write a program that prompts the user to enter the resistance of n resistors. The user should
be prompted continuously by using a while loop until a zero or negative value is entered (the
program should count the number of resistors n entered by the user and store the values in an
array). Use another separate loop to print the resistance values entered by the user and the
equivalent resistance Reg. Test your program with R1= 1 kn, R2= 2 kn, R3= 4 kQ and R4= 8 kQ.
A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree (i.e., the polygon is both equilateral and equiangular). The formula for computing the area of a regular polygon is
Area = ( n * s2 ) / (4 * tan( π/n)
Here, s is the length of a side. Write a program that prompts the user to enter the number of sides and their length of a regular polygon and displays its area.
In Python
input 1 and input 2’s degree is 4
If input 1 and input 2 have same parents, result return 0
Else if input 1 and input 2 have same grandparents , result return 1
Else if input 1 and input 2 have same great_grandparents , result return 2
Else if input 1 and input 2 have same great_great_grandparents , result return 3
Continue until found they have the same great_great_great…._grandparents,
For adding one great, result +1
Else: if no relationship between two input, return -1
tree = [[‘Max’, None , None],
[‘Luc’, ‘Max’, None],
[‘Lue’, ’Max’, None],
[‘Joy’, ‘Luc’, ‘Yoyo’],
[‘Eva’, ‘Joy’, ‘Zoe’,],
[‘Julie’, ‘Geo’, ‘Eva’],
[‘input1’, ‘Brand’, ‘Julie’],
[‘Jim’, ‘Lue’, ‘Rae’],
[‘Gil’, ‘Jim’, ‘Ree’],
[‘Rose’, ‘Gil’, ‘Mandy’]
[‘input2’, ‘James’, ‘Rose’]
this follow by [people, father, mother]
Make the function def degree(input1, input 2, tree)
Chapter 5 Solutions
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Ch. 5.1 - Prob. 1QECh. 5.1 - Prob. 2QECh. 5.1 - Prob. 3QECh. 5.1 - Suppose the insertion sort as presented in Figure...Ch. 5.2 - A primitive in one context might turn out to be a...Ch. 5.2 - Prob. 2QECh. 5.2 - The Euclidean algorithm finds the greatest common...Ch. 5.2 - Describe a collection of primitives that are used...Ch. 5.3 - Prob. 2QECh. 5.3 - Prob. 3QE
Ch. 5.3 - Prob. 4QECh. 5.4 - Modify the sequential search function in Figure...Ch. 5.4 - Prob. 2QECh. 5.4 - Some of the popular programming languages today...Ch. 5.4 - Suppose the insertion sort as presented in Figure...Ch. 5.4 - Prob. 5QECh. 5.4 - Prob. 6QECh. 5.4 - Prob. 7QECh. 5.5 - What names are interrogated by the binary search...Ch. 5.5 - Prob. 2QECh. 5.5 - What sequence of numbers would be printed by the...Ch. 5.5 - What is the termination condition in the recursive...Ch. 5.6 - Prob. 1QECh. 5.6 - Give an example of an algorithm in each of the...Ch. 5.6 - List the classes (n2), (log2n), (n), and (n3) in...Ch. 5.6 - Prob. 4QECh. 5.6 - Prob. 5QECh. 5.6 - Prob. 6QECh. 5.6 - Prob. 7QECh. 5.6 - Suppose that both a program and the hardware that...Ch. 5 - Prob. 1CRPCh. 5 - Prob. 2CRPCh. 5 - Prob. 3CRPCh. 5 - Select a subject with which you are familiar and...Ch. 5 - Does the following program represent an algorithm...Ch. 5 - Prob. 6CRPCh. 5 - Prob. 7CRPCh. 5 - Prob. 8CRPCh. 5 - What must be done to translate a posttest loop...Ch. 5 - Design an algorithm that when given an arrangement...Ch. 5 - Prob. 11CRPCh. 5 - Design an algorithm for determining the day of the...Ch. 5 - What is the difference between a formal...Ch. 5 - Prob. 14CRPCh. 5 - Prob. 15CRPCh. 5 - The following is a multiplication problem in...Ch. 5 - Prob. 17CRPCh. 5 - Four prospectors with only one lantern must walk...Ch. 5 - Starting with a large wine glass and a small wine...Ch. 5 - Two bees, named Romeo and Juliet, live in...Ch. 5 - What letters are interrogated by the binary search...Ch. 5 - The following algorithm is designed to print the...Ch. 5 - What sequence of numbers is printed by the...Ch. 5 - Prob. 24CRPCh. 5 - What letters are interrogated by the binary search...Ch. 5 - Prob. 26CRPCh. 5 - Identity the termination condition in each of the...Ch. 5 - Identity the body of the following loop structure...Ch. 5 - Prob. 29CRPCh. 5 - Design a recursive version of the Euclidean...Ch. 5 - Prob. 31CRPCh. 5 - Identify the important constituents of the control...Ch. 5 - Identify the termination condition in the...Ch. 5 - Call the function MysteryPrint (defined below)...Ch. 5 - Prob. 35CRPCh. 5 - Prob. 36CRPCh. 5 - Prob. 37CRPCh. 5 - The factorial of 0 is defined to be 1. The...Ch. 5 - a. Suppose you must sort a list of five names, and...Ch. 5 - The puzzle called the Towers of Hanoi consists of...Ch. 5 - Prob. 41CRPCh. 5 - Develop two algorithms, one based on a loop...Ch. 5 - Design an algorithm to find the square root of a...Ch. 5 - Prob. 44CRPCh. 5 - Prob. 45CRPCh. 5 - Design an algorithm that, given a list of five or...Ch. 5 - Prob. 47CRPCh. 5 - Prob. 48CRPCh. 5 - Prob. 49CRPCh. 5 - Prob. 50CRPCh. 5 - Prob. 51CRPCh. 5 - Does the loop in the following routine terminate?...Ch. 5 - Prob. 53CRPCh. 5 - Prob. 54CRPCh. 5 - The following program segment is designed to find...Ch. 5 - a. Identity the preconditions for the sequential...Ch. 5 - Prob. 57CRPCh. 5 - Prob. 1SICh. 5 - Prob. 2SICh. 5 - Prob. 3SICh. 5 - Prob. 4SICh. 5 - Prob. 5SICh. 5 - Is it ethical to design an algorithm for...Ch. 5 - Prob. 7SICh. 5 - Prob. 8SI
Knowledge Booster
Similar questions
- You can approximate e using the following summation: Write a program that displays the e value for i = 10000, 20000, …, and 100000.arrow_forwardThe Taylor’s series for cos(x) is given as cos(x)=∑∞ n=0(-1)^n x^2n/2n!= 1-x^2/2!+x^4/4!-x^6/6!+…. The program to calculate cos(x) should use three recursive functions:float power (float x, float n);float fact (float n);float cosine (float x, float n); Write a c programarrow_forwardThe value of π can be approximated by using the following series:π=4(1-(1/3)+(1/5)-(1/7)+...+(1/(2n-1))+(1/(2n+1)))The following program uses this series to find the approximate value of π. However, the statements are in the incorrect order, and there is also a bug in this program. Rearrange the statements and remove the bug so that this program can be used to approximate π.#include <iostream>#include <iomanip>using namespace std;int main(){double pi = 0;long i;long n; cin >> n; cout << "Enter the value of n: "; cout << endl;if (i % 2 == 0) pi = pi + (1 / (2 * i + 1));else pi = pi - (1 / (2 * i + 1));for (i = 0; i < n; i++) { pi = 0;pi = 4 * pi;}cout << endl << "pi = " << pi << endl; return 0;}arrow_forward
- Help me answer to question 4.all question is relate thanks. 1. Write a program to iteratively compute Fibonacci numbers (named after an Italian mathematician).Some Fibonacci numbers are 1, 1, 2, 3, 5, 8, ... where the next number is found by summing the preceding two numbers. Your program will read in a number, like 7, report the first 7 numbers. in this case1,1,2,3,5,8,13. Your program is not assured of receiving good data, thus if -2 is received as the number of numbers, then an error should be reported. 2. Assume that an input string consists of a string of 32 0’s and 1’s representing a binary number. a) Write a program that will convert this binary integer to its base 10 representation. b) Given a string representation of an integer in base 10 convert this integer to its binary representation. The output should consist of a string of 32 0’s and 1’s representing the binary number. 3. You are working for a software firm that is to develop a word processor. In order to create an…arrow_forwardWrite an algorithm to solve the following price-averaging program that asks the user how many products they have purchased on a recent shopping trip. You can assume they will enter a positive integer value. Next, prompt the user for the amount they paid for each product and calculate their average cost per product, formatted to two decimal points. You can assume the user will enter floating-point numbers, but you should constrain users to positive values only. You do not need to prompt the user at the end of the program to see if they wish to continue. Here is a sample running of this program: How many products did you purchase? 3 1 How much did this product cost? 54.00 2 How much did this product cost? -100 Sorry, only positive values allowed. Please try again. 2 How much did this product cost? 98.00 3 How much did this product cost? 87.00 Average Cost: 79.67arrow_forwardMore sophisticated computer-assisted instruction systems monitor the student’s perfor- mance over a period of time. The decision to begin a new topic is often based on the student’s success with previous topics. Write a program that will help an elementary-school student learn multiplication. Use Math.random to produce two positive one-digit integers. To count the number of correct and incorrect responses typed by the student. After the student answers 10 questions, your program should calculate the percentage of correct responses. If the percentage is lower than 75 percent, display Please ask your instructor for extra help, and reset the quiz so another student can try it.arrow_forward
- Task 9 Write Python code of a program that reads an integer, and prints the integer if it is a multiple of NEITHER 2 NOR 5. For example, 1, 3, 7, 9, 11, 13, 17, 19, 21, 23, 27, 29, 31, 33, 37, 39 ... hint(1): use the modulus (%) operator for checking the divisibility hint(2): You can consider the number to be an integer !%3%===== Example01: Input: 3 Output: 3arrow_forwardAnalyze the behavior of the following program, which computes the nth Fibonacci number, for appropriate values of n. Obtain the frequency count of the statements (that are given line numbers) for various cases of n. procedure Fibonacci (n) read (n); if (n<0) then print if (n=0) then print exit(); 8-10. if (n=1) then print ("Fibonacci number is 1"); exit(); 1. 2-4. 5-7. 11-12. f1=0; f2=1; for i 2 to n do 13. 14-16. f = f1 + f2; f1 = £2; £2 = £; print("Fibonacci number is", f); end ("error"); exit(); ("Fibonacci number is 0"); 17. 18. end Fibonacciarrow_forwardGive an example of program that calculate the following sum:arrow_forward
- discrete math programing python or c++ the range of values is from 0 to 5 Let Q(x, y) denote “x + y = 5” The domain of x and y is from range 0 to 5 . Implement the code that outputs the truth values of the following quantifications: 1. ∀x ∀y Q(x, y) 2. ∀x ∃y Q(x, y) **Display values of variables x and y if the quantification is true.arrow_forwardIn number theory, a narcissistic number in a given number base is a number that is the sum of its own digits each raised to the power of the number of digits. Create a program to check whether a given number is Armstrong number Or not.arrow_forwardWrite a program that counts the number of integers from 1 to M that are divisible by N. Use the sample run as guide. Note, that the program repeats until an invalid input is encountered. Sample run: Program to count the number of integers from 1 to M that are divisible by N. Enter M (>1): 3 Enter N (>1): 4 There are no integers from 1 to 3 that are divisible by 4. Enter M (>1): 4 Enter N (>1): 2 There are 2 integers from 1 to 4 that are divisible by 2. Enter M (>1): 4 Enter N (>1): 3 There is 1 integer from 1 to 4 that is divisible by 3. Enter M (>1): -5 You have entered an invalid input. Program will now terminate.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr