Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134700144
Author: Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 5.11, Problem 5.11.2CP
In Listing 5.11. why is it wrong if you change the code (char) (hexValue + ‘0’) to hexValue + '0' in line 21?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In c++
Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, th
backwards End each loop with a newline. Ex If courseGrades (7, 9, 11, 10), print:
7 9 11 10
10 11 9 7
Hint Use two for loops. Second loop starts with i=NUM VALS-1. (Notes)
Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int
courseGrades(4) See 'How to Use zyBooks
Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test
may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't
print the test case that caused the reported message
32344345730rity?
2 using namespace std;
3
4 int main() {
5
6
7
8
9
10
11
12
13
14
const int NUM VALS-4;
int courseGrades [NUM VALS];
int i;
for (i = 0; i > courseGrades[1];
}
y Your solution goes here Y
c++
The Lock class of the preceding problem has a small problem. It does not support combinations that start with one or more zeroes. For example, a combination of 0042 can be opened by entering just 42.
Solve this problem by choosing a different representation. Instead of an integer, use a string to hold the input.
Once again, the combination is hardwired. You will see in Section 9.6 how to change it.
Complete the following file:
C++
NOTES FROM MY TEACHER: okay, first your gonna need to set your curPtr to null. Otherwise, the while is just not going to run. I'm assuming your next is the new head pointer so u should be setting that to the tail pointer since you are reversing. I suggest u change the parameters to loop through the entire list, so u might want to create a variable that goes from 0 to the end of your list and increases every time the while is running and will stop once it gets past the item count otherwise it's going to go on forever. Also put some if statements inside the while for cases where it the beginning of the list, end of the list, and in between the list ur gonna need those because, since its a doubly-linked list, ur also going to have to change the pointers to and from the Null pointers
Please help me fix my reverse function C++
Chapter 5 Solutions
Introduction to Java Programming and Data Structures Comprehensive Version (11th Edition)
Ch. 5.2 - Prob. 5.2.1CPCh. 5.2 - How many times are the following loop bodies...Ch. 5.2 - Prob. 5.2.3CPCh. 5.3 - What is wrong if guess is initialized to 0 in line...Ch. 5.4 - Revise the code using the System. nanoTime () to...Ch. 5.5 - Prob. 5.5.1CPCh. 5.6 - Prob. 5.6.1CPCh. 5.6 - What are the differences between a while loop and...Ch. 5.7 - Do the following two loops result in the same...Ch. 5.7 - What are the three parts of a for loop control?...
Ch. 5.7 - Suppose the input is 2 3 4 5 0. What is the output...Ch. 5.7 - What does the following statement do? for ( ; ; )...Ch. 5.7 - If a variable is declared in a for loop control,...Ch. 5.7 - Convert the following for loop statement to a...Ch. 5.7 - Count the number of iterations in the following...Ch. 5.8 - Can you convert a for loop to a while loop? List...Ch. 5.8 - Can you always convert a while loop into a for...Ch. 5.8 - Identify and fix the errors in the following code:...Ch. 5.8 - Prob. 5.8.4CPCh. 5.9 - How many times is the println statement executed?...Ch. 5.9 - Show the output of the following programs. (Hint:...Ch. 5.11 - Will the program work if n1 and n2 are replaced by...Ch. 5.11 - In Listing 5.11. why is it wrong if you change the...Ch. 5.11 - In Listing 5. 11, how many times the loop body is...Ch. 5.11 - Prob. 5.11.4CPCh. 5.11 - Prob. 5.11.5CPCh. 5.12 - What is the keyword break for? What is the keyword...Ch. 5.12 - The for loop on the left is converted into the...Ch. 5.12 - Rewrite the programs TestBreak and TestContinue in...Ch. 5.12 - After the break statement in (a) is executed in...Ch. 5.13 - What happens to the program if (low high) in line...Ch. 5.14 - Simply the code in lined 27-32 using a conditional...Ch. 5 - (Count positive and negative numbers and compute...Ch. 5 - (Repeat additions) Listing 5.4,...Ch. 5 - (Conversion from kilograms to pounds) Write a...Ch. 5 - (Conversion from miles to kilometers) Write a...Ch. 5 - (Conversion from kilograms to pounds and pounds to...Ch. 5 - Prob. 5.6PECh. 5 - (Financial application: compute future tuition)...Ch. 5 - (Find the highest score) Write a program that...Ch. 5 - (Find the two highest scores) Write a program that...Ch. 5 - (Find numbers divisible by 5 and 6) Write a...Ch. 5 - (Find numbers divisible by 5 or 6, but not both)...Ch. 5 - (Find the smallest n such that n2 12,000) Use a...Ch. 5 - (Find the largest n such that n3 12,000) Use a...Ch. 5 - (Compute the greatest common divisor) Another...Ch. 5 - (Display the ASCII character table) Write a...Ch. 5 - (Find the factors of an integer) Write a program...Ch. 5 - (Display pyramid) Write a program that prompts the...Ch. 5 - (Display four patterns using Loops) Use nested...Ch. 5 - (Display numbers in a pyramid pattern) Write a...Ch. 5 - (Display prime numbers between 2 and 1,000) Modify...Ch. 5 - Prob. 5.21PECh. 5 - For the formula to compute monthly payment, see...Ch. 5 - (Demonstrate cancellation errors) A cancellation...Ch. 5 - Prob. 5.24PECh. 5 - (Compute ) You can approximate by using the...Ch. 5 - (Compute e) You can approximate e using the...Ch. 5 - (Display leap years) Write a program that displays...Ch. 5 - (Display the first days of each month) Write a...Ch. 5 - (Display calendars) Write a program that prompts...Ch. 5 - (Financial application: compound value) Suppose...Ch. 5 - (Financial application: compute CD value) Suppose...Ch. 5 - (Game: lottery) Revise Listing 3.8, Lottery.java,...Ch. 5 - (Perfect number) A positive integer is called a...Ch. 5 - (Game: scissor; rock, paper) Programming Exercise...Ch. 5 - (Summation) Write a program to compute the...Ch. 5 - (Business application: checking ISBN) Use loops to...Ch. 5 - (Decimal to binary) Write a program that prompts...Ch. 5 - (Decimal to octal) Write a program that prompts...Ch. 5 - (Financial application: find the sales amount) You...Ch. 5 - (Simulation: heads or tails) Write a program that...Ch. 5 - (Occurrence of max numbers) Write a program that...Ch. 5 - (Financial application: find the sales amount)...Ch. 5 - (Math: combinations) Write a program that displays...Ch. 5 - (Computer architecture: bit-level operations) A...Ch. 5 - (Statistics: compute mean and standard deviation)...Ch. 5 - (Reverse a string) Write a program that prompts...Ch. 5 - (Business: check ISBN-13) ISBN -13 is a new...Ch. 5 - (Process string) Write a program that prompts the...Ch. 5 - (Count vowels and consonants) Assume that the...Ch. 5 - Prob. 5.50PECh. 5 - (Longest common prefix) Write a program that...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Add a default: constructor to the Circle class in Question 43. The constructor should initialize the radius mem...
Starting Out with C++ from Control Structures to Objects (9th Edition)
Here is the first line of a class declaration. What is the name of the superclass? What is the name of the subc...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Why is the study of database technology important?
Database Concepts (8th Edition)
Consider the following C program void fun (void) { int a, b, c; / defiinition.1 / . . . while (. . .) int b, c,...
Concepts Of Programming Languages
Theprogramming language is now used to develop large-scale enterprise applications, to enhance the functionalit...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
The current source in the circuit shown generates the current pulse
Find (a) v (0); (b) the instant of time gr...
Electric Circuits. (11th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- C++ NOTES FROM MY TEACHER: okay, first your gonna need to set your curPtr to null. Otherwise, the while is just not going to run. I'm assuming your next is the new head pointer so u should be setting that to the tail pointer since you are reversing. I suggest u change the parameters to loop through the entire list, so u might want to create a variable that goes from 0 to the end of your list and increases every time the while is running and will stop once it gets past the item count otherwise it's going to go on forever. Also put some if statements inside the while for cases where it the beginning of the list, end of the list, and in between the list ur gonna need those because, since its a doubly-linked list, ur also going to have to change the pointers to and from the Null pointers Please help me fix my reverse function C++arrow_forwardWrite in c++arrow_forwardIn standard C programmingarrow_forward
- What are the chances that the REpitition code, often known as the Huffman code, will include a mistake?arrow_forwardQ2. A. write a code to find the number of students who pass CS course, when their marks>=40 . As the list has 85 students. ( list must show how many students passed/failed) use htmp or py B. wite a code to print this shape: * * * * * * * * * * C. Write a code to find the area and parameter of a Tringle; Area =1/2 * High * Base Parameter= S1+S2+ Basearrow_forwardin c++ vs2019 You should write a program to sort an array. For this purpose you will implement two sorting algorithms: Insertion Sort and Merge Sort. For each algorithm, you are supposed to have a counter and count how many times a comparison is made to sort the array. Once this logic is implemented, create integer arrays of 1000 and 10000 elements with random values inside (you can implement a random number generator for this purpose and randomize their elements). Then go ahead and run your application. The output should show us how many comparisons it made for each algorithm for 1000 and 10000 elements. Do it seperate files. 1 cpp file 1 header file 1 main.cpp filearrow_forward
- 1. Formula for cell A15 that adds all data from B1 to D6 2. Formula for cell A16 that determines the lowest number found on A1, A2, A3, B1, B2, and B3 3. If you had a cell reference C5, but in your formula you want C to stay constant and 5 to change, what would be the correct structure? 4. If you have a list of numbers in cells B2 through B20 and you wanted the average of these numbers, what would be the formula? 5. Assume you are copying cell A1 to cell C3. If cell A1 contains the formula =$B1+$C$1, how would this formula change when copied to cell C3?arrow_forward*C Programming This exercise is to help you learn how to debug compiler warnings/errors and other common errors in your code. For each part labeled P(n), there is a warning/error/problem that goes with it. Write down what the issue was in the `Error:` section of each problem. Work on `segfault.c` along with your fixes and error comments. segfault.c file // P0#include <stdio.h>#include <stdlib.h>/* Error: */ void fib(int* A, int n); intmain(int argc, char *argv[]) {int buf[10];unsigned int i;char *str;char *printThisOne;char *word;int *integers;int foo;int *bar;char *someText; // P1for (i = 0; i <= 10; ++i) { buf[i] = i;}for (i = 0; i <= 10; ++i) { printf("Index %s = %s\n", i, buf[i]);}/* Error: */ // P2str = malloc(sizeof(char) * 10);strcpy(str, "Something is wrong");printf("%s\n", printThisOne);/* Error: */ // P3word = "Part 3";*(word + 4) = '-';printf("%s\n", word);/* Error: */ // P4*(integers + 10) = 10;printf("Part 4: %d\n", *(integers +…arrow_forwarding Your goal is to modify your Assignment 6 program to allow the user to pick up a random item and display a sorted list of the contents of the knap sack. Note: If you use the built in C++, the most you can make on this assignment is 4 out of 10. You are expected to right your own sort based on one of the algorithms covered in class. Your program should have the following: • The name of the program should be Assignment 6. • 3 comment lines (description of the program, author, and date). • Modify your Assignment 5 program to do the following: o Display a menu (use a switch statement to implement the menu) of actions ▪ Attack: • For now, just display that the user chose to attack ▪ Pick up Item: • Randomly add one of 6 items to an array named knapSack o You get to choose the item names • Display which item the user picked up ▪ Add an option to the main switch statement: Display Knap Sack contents • The contents of the knap sack must be sorted Make the code easy…arrow_forward
- Write VBA CODE FOR THE FOLLOWING PROBLEM Problem: The Worksheet named Grades contains a place for students to record the grades they have received in their classes. Students put the number of each letter grade received in the B column. (For example, the worksheet currently shows that the student has taken 9 classes and made five As, one B, one C, one D, and one F as grades. You need to write a program that reads the grades from the worksheet and uses a function to calculate the student’s GPA. For this problem you can assume that all classes are worth the same number of credit hours. The function should send back the GPA to the calling procedure. The procedure will then put up a message box that gives the student their GPA and a message about their GPA, all in one message box. The message should be “You qualify for an internship” if the student has a GPA of at least 3.0. It should be “You’re in the danger zone” if the GPA is between 2.0 and 3.0. And it should be “You are on…arrow_forwardIn C(notC++ or C#), I am trying to code a program without the use of arrays and strings that asks for values from the user and find out which number was entered the most number of times (mode) and how many times this number was entered (frequency). Stop asking for values once a -1 has been entered Following is my code but it seems to have an error. Can someone fix it. #include <stdio.h> int main() { int nNum,current,previous,frequency=1,maxFrequency=0,mode; do { printf("Enter a Number: "); scanf("%d", &nNum); previous=nNum; if(nNum==previous) frequency++; else { if(frequency>=maxFrequency) { maxFrequency=frequency; mode=previous; } frequency=1; }} while (nNum!=-1); printf("The mode is %d and its frequency is…arrow_forwardIn C#: Run the following console application. This program should produce the union of two sets, but has several errors. Use a variety of debugging techniques to locate and correct the errors. NOTE: A set is a collection of like elements that does not contain any duplicates. The union of two sets is the set that contains all the elements in both sets. Formally: A union B = {x : x Î A or x Î B}read: A union B is the set of all x such that x is in A or x is in B Example: A = {1,2,3,4,5} and B = {2,4,6,8}, then A union B = {1,2,3,4,5,6,8} (notice, no duplicates!) Debug the program. When you find an error, comment out the offending line, give an explanation of the error, write a corrected line, and include a screenshot of your program running with successful output. Submit the modified files and screenshots of any breakpoints you use. Program using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace…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 LearningNew Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Program to find HCF & LCM of two numbers in C | #6 Coding Bytes; Author: FACE Prep;https://www.youtube.com/watch?v=mZA3cdalYN4;License: Standard YouTube License, CC-BY