Write a program that reads the integers between 1 and 100 and counts the occurrences of each. Assume the input ends with 0. Hereis a sample run of the program: If a number occurs more than one time,...
Write a program that displays two circles with radius 10 at location (40, 40) and (120, 150) with a line connecting the two circles, as shown in Figure 15.28b. The distance between the circles is...
Write the following two generic methods using bubble sort. The first method sorts the elements using the Comparable interface and the second uses the Comparator interface. public static void...
Write a program that uses a pie chart to display the percentages of the overall grade represented by projects, quizzes, midterm exams, and the final exam, as shown in Figure 14.46c. Suppose that...
Suppose that in a 0-1 knapsack problem, the order of the items when sorted by increasing weight is the same as their order when sorted by decreasing value. Give an efficient algorithm to find an...
Prove that if p 1 p 2 is positive, then vector p 1 is clockwise from vector p 2 with respect to the origin (0, 0) and that if this cross product is negative, then p 1 is counterclockwise from p 2 .
Draw a class inheritance diagram for the following set of classes: Class Goat extends Object and adds an instance variable tail and methods milk( ) and jump( ). Class Pig extends Object and adds an...
Programming Exercise 7.6 describes how to perform matrix multiplication. Suppose you have multiple processors, so you can speed up the matrix multiplication. Implement the following method in...
Show the longest common subsequence array L for the two strings: X = "skullandbones" Y = "lullabybabies" What is a longest common subsequence between these strings?
Modify Listing 28.10, ConnectedCircles.java, to enable the user to remove a circle when the mouse is clicked inside the circle. Listing 1 import javafx.application. Application; 2 import...
Draw the recursion trace for the execution of method PuzzleSolve(3,S,U), from Code Fragment 5.11, where S is empty and U = {a,b,c,d}. Algorithm PuzzleSolve(k, S, U): Input: An integer k, sequence S,...
The following questions refer to the tree of Figure 8.3.a. Which node is the root?b. What are the internal nodes?c. How many descendants does node cs016/ have?d. How many ancestors does node cs016/...
Convert the number 101000101100 2 directly from binary to hexadecimal. Without looking at the original number, convert your answer directly back to binary and compare your final answer with the...
Identify and briefly explain two different ways of configuring a multiprocessing system. Which configuration is more effective for general-purpose computing? Which configuration is more effective for...
Create a JavaFX application for Paulas Portraits, a photography studio. The application allows users to compute the price of a photography session. Paulas base price is $40 for an in-studio photo...
Open the VB2017\Chap06\FixIt Solution\FixIt Solution.sln file. Start the application. Click 20 in the Length combo box and then click 30 in the Width combo box. Click the Calculate area button, which...
In this exercise, you modify the Check Digit application from this chapters Apply lesson. Use Windows to make a copy of the Check Digit Solution folder. Rename the copy Check Digit Solution-ForNext....
Are function names case sensitive?
In this exercise, you code the Professor Schneider application, which displays a grade based on the number of points entered by the user. The number of points should always be less than or equal to...
What is the difference between the downcase and downcase! methods?
Write an HDL module for the traffic light controller from Section 3.4.1.
What is the delay for the following types of 64-bit adders? Assume that each two-input gate delay is 150 ps and that a full adder delay is 450 ps. (a) a ripple-carry adder (b) a carry-lookahead adder...
Write the following strings using ASCII encoding. Write your final answers in hexadecimal. (a) SOS (b) Cool! (c) (your own name)
Repeat Exercise 6.3 for memory storage of a 32-bit word stored at memory word 15 in a byte-addressable memory.? Data from problem 3 Consider memory storage of a 32-bit word stored at memory word 42...
Let T be a heap storing n keys. Give an efficient algorithm for reporting all the keys in T that are smaller than or equal to a given query key x (which is not necessarily in T). For example, given...
Answer the previous exercise assuming that we implement both the union-bysize and path compression heuristics.
Consider the recurrence equation,
Suppose that in an instance of the coins-in-a-line game the coins have the following values in the line: (9, 1, 7, 3, 2, 8, 9, 3). What is the maximum that the first player, Alice, can win, assuming...
Let S = {a, b, c, d, e, f, g} be a collection of objects with benefit-weight values, a: (12, 4), b : (10, 6), c : (8, 5), d: (11, 7), e: (14, 3), f : (7, 1), g : (9, 6). What is an optimal solution...
Suppose that CONTROL, a secret U.S. government counterintelligence agency based in Washington, D.C., has build a communication network that links n stations spread across the world using m...
Suppose you are a manager in the IT department for the government of a corrupt dictator, who has a collection of computers that need to be connected together to create a communication network for his...
Answer the following questions on the flow network N and flow f shown in Figure 16.6a: What are the forward and backward edges of augmenting path ? How many augmenting paths are there with respect to...
Suppose an oracle has given you a magic computer, C, that when given any Boolean formula B in CNF will tell you in one step whether B is satisfiable. Show how to use C to construct an actual...
Prove that the set of feasible solutions to a linear program with a nonempty feasible region is convex.
All of the employees at Merks Sales are paid based on an annual salary rather than an hourly wage. However, some employees are paid weekly while others are paid every other week (biweekly). Weekly...
The algorithm shown in Figure 1-14 should calculate and print the gross pay for five workers; however, some of the instructions are missing from the algorithm. Complete the algorithm. If an employee...
Write the C++ code for a function that receives four items of information: three by value and one by reference. Each item has the double data type. Name the formal parameters num1, num2, num3, and...
Mountain Coffee wants a program that allows a clerk to enter the number of pounds of coffee ordered, the price per pound, and whether the customer should be charged a 3.5% sales tax. The program...
Create a program that displays a multiplication table similar to the one shown in Figure 7-51. If necessary, create a new project named Introductory20 Project, and save it in the Cpp8\Chap07 folder....
If necessary, create a new project named Introductory20 Project and save it in the Cpp8\Chap13 folder. Also create a new source file named Introductory20.cpp. Write a program that displays the...
If necessary, create a new project named Intermediate23 Project and save it in the Cpp8\Chap13 folder. Also create a new source file named Intermediate23.cpp. Write a program that displays the color...
Which of the following is valid advice for naming variables? a. To save typing, make most variable names one or two letters. b. To avoid conflict with names that others are using, use unusual or...
If productCost and productPrice are numeric variables, and productName is a string variable, which of the following statements are valid assignments? If a statement is not valid, explain why not.
Assume that speed = 10 and miles = 5. What is the value of each of the following expressions?
Which of the following is true of structured logic? a. You can use structured logic with newer programming languages, such as Java and C#, but not with older ones. b. Any task can be described using...
Choose a television game show such as Wheel of Fortune or Jeopardy! and describe its rules using a structured flowchart or pseudocode.
A trivial Boolean expression is one that ______________. a. Is uses only two operands b. Always has the same value c. Is always true d. Is always false
If d is true, e is false, and f is false, which of the following expressions is true? a. e OR f AND d b. f AND d OR e c. d OR e AND f d. two of the above
ShoppingBay is an online auction service that requires several reports. Data for each auctioned item includes an ID number, item description, length of auction in days, and minimum required bid....
In Chapter 2, you learned that many programming languages allow you to generate a random number between 1 and a limiting value named limit by using a statement similar to randomNumber =...
Create the logic for a game that simulates rolling two dice by generating two numbers between 1 and 6 inclusive. The player chooses a number between 2 and 12 (the lowest and highest totals possible...
Suppose that you have declared a numeric array named numbers, and two of its elements are numbers[1] and numbers[4]. You know that _________. a. The two elements hold the same value b. The array...
A _________is a variable that can be set to indicate whether some event has occurred. a. Subscript b. Banner c. Counter d. Flag
a. Daily Life Magazine wants an analysis of the demographic characteristics of its readers. The Marketing department has collected reader survey records containing the age, gender, marital status,...
If necessary, create a new project named Introductory19 Project and save it in the Cpp8\Chap14 folder. Also create a new source file named Introductory19.cpp. Create a program that saves a companys...
Random access memory is ___________. a. Volatile b. Permanent c. Persistent d. Continual
Every file on a storage device has a ____________. a. Name b. Size c. Both of the above d. None of the above
The process of _________ a file locates it on a storage device and associates a variable name within your program with the file. a. Declaring b. Closing c. Opening d. Defining
When you write to a file, you ______________. a. Move data from a storage device to memory b. Copy data from a storage device to memory c. Move data from memory to a storage device d. Copy data from...
Unlike when you print a report or display information on a screen, when a programs output is a data file, you do not _________. a. Include explanations or formatting such as dollar signs b. Open or...
When you close a file, it __________. a. Becomes associated with an internal identifier b. Cannot be reopened c. Is no longer available to the program d. Ceases to exist
A file in which records are stored one after another in order based on the contents of a field is a(n) __________ file. a. Temporal b. Alphabetical c. Random d. Sequential
When you combine two or more sorted files while maintaining their sequential order based on a field, you are __________ the files. a. Tracking b. Collating c. Merging d. Absorbing
A control break occurs when a program _____________. a. Pauses to perform special processing based on the value of a field b. Ends prematurely, before all records have been processed c. Takes one of...
A control break field __________. a. Always is output prior to any group of records on a control break report b. Always is output after any group of records on a control break report c. Never is...
Which of the following is an example of a control break report? a. A list of all customers of a business in zip code order, with a count of the number of customers who reside in each zip code b. A...
Whenever a control break occurs during record processing in any control break program, you must _________. a. Declare a control break field b. Set the control break field to 0 c. Update the value in...
Assume that you are writing a program to merge two files named FallStudents and SpringStudents. Each file contains a list of students enrolled in a programming logic course during the semester...
When you merge records from two or more sequential files, the usual case is that the records in the files _______. a. Contain the same data b. Have the same format c. Are identical in number d. Are...
A file that holds more permanent data than a transaction file is a _________file. a. Master b. Primary c. Key d. Mega-
A transaction file is often used to ____________ another file. a. Augment b. Remove c. Verify d. Update
The saved version of a file that does not contain the most recently applied transactions is known as a ____________ file. a. Master b. Child c. Parent d. Relative
Random access files are used most frequently in all of the following except _______________. a. Interactive programs b. Batch processing c. Real-time applications d. Programs requiring direct access
Laramie Park District has files of participants in its summer and winter programs this year. Each file is in participant ID number order and contains additional fields for first name, last name, age,...
The Curl Up and Dye Beauty Salon maintains a master file that contains a record for each of its clients. Fields in the master file include the clients ID number, first name, last name, and total...
The International Rock Paper Scissors Society holds regional and national championships. Each region holds a semifinal competition in which contestants play 500 games of Rock Paper Scissors. The top...
Employee records stored in order from highest-paid to lowest-paid have been sorted in _____ order. a. Descending b. Ascending c. Staggered d. Recursive
Student records stored in alphabetical order by last name have been sorted in _____ order. a. Descending b. Ascending c. Staggered d. Recursive
When computers sort data, they always _____. a. Place items in ascending order b. Use a bubble sort c. Use numeric values when making comparisons d. Begin the process by locating the position of the...
Which type of sort compares list items in pairs, swapping any two adjacent values that are out of order? a. Insertion sort b. Indexed sort c. Bubble sort d. Selection sort
To sort a list of 15 values using a bubble sort, the greatest number of times you would have to pass through the list making comparisons is _____. a. 15 b. 14 c. 13 d. 12
To completely sort a list of 10 values using a bubble sort, the greatest possible number of required pair comparisons is _____. a. 9 b. 10 c. 81 d. 100
When you do not know how many items need to be sorted in a program, you can create an array that has _____. a. Variable-sized elements b. At least as many elements as the number you predict you will...
In a bubble sort, on each pass through the list that must be sorted, you can stop making pair comparisons _____. a. One comparison sooner b. Two comparisons sooner c. One comparison later d. Two...
When performing a bubble sort on a list of 10 values, you can stop making passes through the list of values as soon as _____ on a single pass through the list. a. No swaps are made b. Exactly one...
The bubble sort is _____. a. The most efficient sort b. A relatively fast sort compared to others c. A relatively easy sort to understand d. All of the above
Data stored in a table that can be accessed using row and column numbers is stored as a _____ array. a. Single-dimensional b. Two-dimensional c. Three-dimensional d. Nondimensional
In a two-dimensional array declared as num myArray[6][7], the highest row number is ______. a. 5 b. 6 c. 7 d. 8
If you access a two-dimensional array with the expression output myArray[2][5], the output value will be _____. a. 0 b. 2 c. 5 d. Impossible to tell from the information given
Assume you have written a method with the header string myMethod(num score, string grade). Also assume you have declared a numeric variable named test. Which of the following is a correct method...
Programmers should strive to _____. a. Increase coupling b. Increase cohesion c. Both of the above d. Neither a nor b
a. Create the logic for a program that performs arithmetic functions. Design the program to contain two numeric variables, and prompt the user for values for the variables. Pass both variables to...
a. Plan the logic for an insurance company program to determine policy premiums. The program continuously prompts the user for an insurance policy number. When the user enters an appropriate sentinel...
Create the logic for a program that prompts the user for numeric values for a month, day, and year. Then pass the three variables to the following methods: a. A method that displays the date with...
The process of acquiring the traits of ones predecessors is ________. a. Polymorphism b. Encapsulation c. Inheritance d. Orientation
An instance method ________. a. Is static b. Receives a this reference c. Both of the above d. None of the above
Assume that you have created a class named Dog that contains a data field named weight and an instance method named setWeight(). Further assume that the setWeight() method accepts a numeric parameter...
A static method is also known as a(n) ________ method. a. Instance b. Class c. Private d. Public
By default, methods contained in a class are ________methods. a. Static b. Nonstatic c. Class d. Public
Assume that you have created a class named MyClass, and that a working program contains the following statement: output MyClass.numberOfStudents Which of the following do you know? a....