Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 11.3, Problem 22STE
Program Plan Intro
- Declare an “double” constant function named “getTemperature()” in the class “TemperatureList”.
- Define a “getTemperature()” function to return the temperature position on the list.
- “if” statement to check the “position” is greater than or equal to “size” or “position” is lesser than “0”.
- The condition is true, print the error message.
- Otherwise, return the temperature position on the list.
- The function having the keyword “const”.
- The keyword “const” will tell the compiler that this member function should not change the value of its calling object.
- “if” statement to check the “position” is greater than or equal to “size” or “position” is lesser than “0”.
- The condition is true, print the error message.
- Otherwise, return the temperature position on the list.
- The function having the keyword “const”.
- The keyword “const” will tell the compiler that this member function should not change the value of its calling object.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
The following is the specification for the constructor of a EmailFolder class:
/*** Creates a new EmailFolder with the given label** @precondition label != null AND !label.isEmpty()* @postcondition getLabel()==label*/public EmailFolder(String label)
Assume the variable folders is an array list of EmailFolder objects.
Write code that gets the tenth item in the list, assigning it to an appropriate variable. (java)
Task 4. Utility classes
Implement a Menu-Driven program of ArrayList class using the above scenario and perform the
following operations.
a. Create an object of ArrayList class based on the scenario with explanations of the method used.
b. Create a method that will allow inserting an element to ArrayList Class based on the scenario. The
input field must be validated as necessary.
C.
Create a method to delete specific elements in the ArrayList with explanations of the method used.
Develop a class named PieChart that extends Canvas for displaying a pie chart using the following constructor:PieChart(parent, data, width = 400, height = 300)
Where data is a list, each element in the list is a nested list that consists of a value, a title for the value, and a color for the wedge in the pie chart. For example, for data = [[40, "CS", "red"], [30, "IS", "blue"], [50,
"IT", "yellow"]], the pie chart is as shown in the left part of Figure 12.29.For data = [[140, "Freshman", "red"], [130, "Sophomore","blue"], [150, "Junior", "yellow"], [80, "Senior","green"]], the pie chart is as shown in the right part of Figure 12.29. Write atest program that displays two pie charts, as shown in Figure 12.29.
Chapter 11 Solutions
Problem Solving with C++ (10th Edition)
Ch. 11.1 - Write a function definition for a function called...Ch. 11.1 - What is the difference between a friend function...Ch. 11.1 - Suppose you wish to add a friend function to the...Ch. 11.1 - Prob. 4STECh. 11.1 - Notice the member function output in the class...Ch. 11.1 - Notice the definition of the member function input...Ch. 11.1 - The Pitfall section entitled Leading Zeros in...Ch. 11.1 - Give the complete definition of the member...Ch. 11.1 - Why would it be incorrect to add the modifier...Ch. 11.1 - What are the differences and the similarities...
Ch. 11.1 - Given the following definitions: const int x = 17;...Ch. 11.2 - What is the difference between a (binary) operator...Ch. 11.2 - Prob. 13STECh. 11.2 - Suppose you wish to overload the operator = so...Ch. 11.2 - Prob. 15STECh. 11.2 - Give the definition for the constructor discussed...Ch. 11.2 - Here is a definition of a class called Pairs....Ch. 11.2 - Following is the definition for a class called...Ch. 11.3 - Give a type definition for a structure called...Ch. 11.3 - Write a program that reads in five amounts of...Ch. 11.3 - Change the class TemperatureList given in Display...Ch. 11.3 - Prob. 22STECh. 11.3 - If a class is named MyClass and it has a...Ch. 11.4 - Prob. 24STECh. 11.4 - The following is the first line of the copy...Ch. 11.4 - Answer these questions about destructors. a. What...Ch. 11.4 - a. Explain carefully why no overloaded assignment...Ch. 11 - Modify the definition of the class Money shown in...Ch. 11 - Self-Test Exercise 17 asked you to overload the...Ch. 11 - Self-Test Exercise 18 asked you to overload the...Ch. 11 - Prob. 1PPCh. 11 - Define a class for rational numbers. A rational...Ch. 11 - Define a class for complex numbers. A complex...Ch. 11 - Enhance the definition of the class StringVar...Ch. 11 - Define a class called List that can hold a list of...Ch. 11 - Define a class called StringSet that will be used...Ch. 11 - This programming project requires you to complete...Ch. 11 - Redo Programming Project 6 from Chapter 9 (or do...Ch. 11 - Solution to Programming Project 11.12 To combat...Ch. 11 - Repeat Programming Project 11 from Chapter 10 but...Ch. 11 - Do Programming Project 19 from Chapter 8 except...
Knowledge Booster
Similar questions
- Define a class called Book. This class should store attributes such as the title, ISBN number, author, edition, publisher, and year of publication. Provide get/set methods in this class to access these attributes. Define a class called Bookshelf, which contains the main method. This class should create a few book objects with distinct names and store them in an ArrayList. This class should then list the names of all books in the ArrayList. Enhance the program by providing a sort function, which will sort the books in ascending order of their year of publication. Create a few more Bookobjects with the same names but with different edition numbers, ISBNs, and years of publication. Add these new Book objects to the ArrayList, and display the book list sorted by book name; for duplicate books of the same name, sort the list by year of publication. (Hint: You will need to define a comparator class that takes two Book objects as parameters of the compareTo This method should do a two-step…arrow_forwardDevelop a class named BarChart that extends Canvas for displaying a bar chart:BarChart(parent, data, width = 400, height = 300)Where data is a list, each element in the list is a nested list that consists of a value, a title for the value, and a color for the bar in the bar chart. For example, for data = [[40, "CS", "red"], [30, "IS", "blue"], [50, "IT","yellow"]], the bar chart is as shown in the left part of Figure 12.28. For data= [[140, "Freshman", "red"], [130, "Sophomore", "blue"],[150, "Junior", "yellow"], [80, "Senior", "green"]], the bar chart is as shown in the right part of Figure 12.28. Write a test program that displays two bar charts, as shown in Figure 12.28.arrow_forwardCreate a Point classCreate a Point class as we did in the class. We'll use this to create Point objects that hold x,y coordinates of locations where we'll want to draw. Draw DotsWrite a drawDots(points) function that takes a list points as input and draws a dot on the drawing window for each Point. For example, you should be able to call your function as follows: >>> p = Point(10, 20) >>> q = Point(20, 30) >>> points = [p, q] >>> drawDots(points)arrow_forward
- Create a class called CustomerListerwith a mainmethod that instantiates an array of Stringobjects called customerName. The array should have room for five Stringobjects. Use an initializer list to put the following names into the array:Cathy Ben Jorge Wanda FreddieUse newto create a second doublearray called customerBalancein the mainmethod. Allow room for five customer balances, each stored as a double.In the loop that prints each customer name, add some code to prompt the user to enter a balance for that customer. Read the keyboard input with a Scannerobject. Use the following balances for the input:100.00234.562.4932.32400.00After all the balances have been entered, print out each customer and his/her balance.arrow_forwardDesign a class called Post. This class models a StackOverflow post. It should have properties for title, description and the date/time it was created. We should be able to up-vote or down-vote a post. We should also be able to see the current vote value. In the main method, create a post, up-vote and down-vote it a few times and then display the the current vote value.arrow_forwardURGENtt!! You are asked to write a java class named "Kume". The UML class diagram of the Kume class is as follows. 3 The elements in the set are kept in an ArrayList. The constructor of the class takes an array of int and adds the elements of this array to the ArrayList named al. The add() method adds an integer it takes as a parameter to the get element. The delete() method deletes an Integer object that it takes as a parameter from the get element, returns true if it can be deleted, otherwise false. The print() function prints the elements of the set to the console. The compareTo() method is inherited from the Object class and is suppressed, and compares the get element of the Set object, which it takes as a parameter, with the retrieve element of the current set object in terms of content (the order of the elements is not important). It returns 1 if both sets contain the same elements, 0 otherwise. Below is a test code that creates two objects from the Kume class and performs…arrow_forward
- Q8. Write a declaration of a private field named department that can hold an ArrayList. The elements of the ArrayList are of type Student. Write an assignment to the department variable to create an appropriate ArrayList object. Q9. (A) If a collection stores 20 objects, what value would be returned from a call to its size method? (B) Write a method call using get to return the fifth object stored in a collection called department. Q10. Write a method call to add the object held in the variable student1 to a collection department files.arrow_forwardPart #2: Write a class called Test equallists having main method to test the application. In main method create following: 1- Object of type ArrayList list1. 2- Add the following data to list1 (4 13 3- Object of type ArrayList list2. 4- Add the following data to list2 (4 2 1 12 5- Object of type ArrayList list3. 6- Test the equallists method to print the result. Example: list1: 4 13 1 list2: 4 2 1 list3: 1 0 8 12 1 9 0 9 0 2 0 OOL 1 0 (generated by the method) 0 150 10 18 19 01). 9205).arrow_forwardCreate a player class and a Key class. A Player hasa name, HP, and a key. A character may only have one key at a time, a Key contains a String array that lists the names of all the placed the key can go. The key should have a use() function that takes in a string of what it is trying to be used on, the function will return true if it can be used on that door, and false if it cannot. The player can pick Up and Drop a key.arrow_forward
- Write the definitions of the member functions of the classes arrayListType and unorderedArrayListType that are not given in this chapter. The specific methods that need to be implemented are listed below. Implement the following methods in arrayListType.h: isEmpty isFull listSize maxListSize clearList Copy constructor Implement the following method in unorderedArrayListType.h insertAt Also, write a program (in main.cpp) to test your function.arrow_forwardTo demonstrate working with ArrayLists, we will be working with four source files: a Dessert class, two classes that extend Dessert called IceCream and Cake, and a TestDessert class. The TestDessert class contains a main() method that declares an ArrayList to hold Dessert objects. This ArrayList is referenced by the variable named "list". Examine TestDessert's main() method and notice the four comments. You are to implement code that accomplishes the tasks described in each step. For step 1, you are to populate the ArrayList with 10 IceCream and Cake objects. These objects should be inserted into the ArrayList at random. This means each run of the program should produce an ArrayList with different proportions of IceCream and Cake objects. After this operation, the ArrayList should contain 10 total objects (IceCream and Cake objects). Display the ArrayList after the operation. For step 2, if the first and last dessert in the ArrayList are different (one is IceCream and the other is…arrow_forwardNeed help with this in Java Implement a “To Do” list. Tasks have a priority between 1 and 9, and a description (which you can come up with on your own, say, “wash dishes”). The program is going to prompt the user to enter the tasks by running the method add_priority_description, the program adds a new task and prints the current list with priority 1 tasks on the top, and priority 9 tasks at the bottom. The program will continue to ask the user if they want to add another tasks, and repeat the add_priority_description method, or enters Q to run the quit method to quit the program. Sample output (not limited to) 1. Study for the final 1. Take the final 2. Watch Justice League with friends 3. Play ball 9. Wash Dishes 9. Clean room. There is a possibility of two tasks having the same priority. If so, the last task that was entered gets to be printed first. Use HEAP in your solution. (Java)arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education