Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 11.3, Problem 21STE
Change the class TemperatureList given in Display 11.10 by adding a member function called getSize, which takes no arguments and returns the number of temperatures on the list.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a deck of cards class. Internally, the deck of cards should use another class, a card class. Your requirements are:
The Deck class should have a deal method to deal a single card from the deck
After a card is dealt, it is removed from the deck.
There should be a shuffle method which makes sure the deck of cards has all 52 cards and then rearranges them randomly.
The Card class should have a suit (Hearts, Diamonds, Clubs, Spades) and a value (A,2,3,4,5,6,7,8,9,10,J,Q,K)
Complete the Course class by implementing the courseSize() method, which returns the total number of students in the course.
Given classes:
Class LabProgram contains the main method for testing the program.
Class Course represents a course, which contains an ArrayList of Student objects as a course roster. (Type your code in here.)
Class Student represents a classroom student, which has three fields: first name, last name, and GPA.
Ex. For the following students:
Henry Bendel 3.6 Johnny Min 2.9
the output is:
Course size: 2
public class LabProgram { public static void main (String [] args) { Course course = new Course(); // Example students for testing course.addStudent(new Student("Henry", "Bendel", 3.6)); course.addStudent(new Student("Johnny", "Min", 2.9)); System.out.println("Course size: " + course.courseSize()); } }
public class Student {
private String first; // first name private String last; // last name private…
In F3, students will be tasked with taking input from a file to create an *Array* of FeetInches (2 parameters). When all the FeetInches have been stored, any FeetInches at least 1 foot will be converted and added to an *ArrayList* of Circles (one parameter). Students will then complete the compareTo method found in the Circle class, sort the ArrayList of Circles, and then output the radius' of the new circle.
The first integer in the file input will tell us how many FeetInches objects will be made using the fileInput, and the numbers after are the data for those Objects. Use this first integer in your for Loops.
A template with main, Circle, and FeetInches class, as well as the file input, is attached below. Please follow along with comments and reach out if you have any questions.
package f3_template;
public class Circle implements Comparable <Circle>{//attribute private int radius; //constructorspublic Circle(){radius=0;}public Circle(int r){radius=r;}//accessorspublic…
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...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
#inc1ude iostream using namespace std; int main() { cout ("hello")[1]; return 0; }
Starting Out with C++: Early Objects (9th Edition)
Consider the following array: int [] a = new int[10]; What is the last index of a? What is the value of a.lengt...
Java: An Introduction to Problem Solving and Programming (8th Edition)
When displaying a Java applet, the browser invokes the _____ to interpret the bytecode into the appropriate mac...
Web Development and Design Foundations with HTML5 (8th Edition)
Code an SQL statement that creates a table with all columns from the parent and child tables in your answer to ...
Database Concepts (8th Edition)
What is a default constructor?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Where do you declare class-level variables?
Starting Out With Visual Basic (8th 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
- 1) Create a "Car" class that keeps car ids and prices. And create a "Galleries" class that holds the car list for a particular gallery. In this class there should be methods for get / set and print for car name, car number and car list. Adding / Removing Cars to the List in This Class should have methods. And create another method to find and print the IDs of Cars with Car Segment equal to X. (print (X)). Car Prices are as follows according to the segments. 0-19999 -> Z20000-29999 -> Y30000-44999 -> T45000-100000 -> P Apply the Car list using "Single Linked List"(Node, newNode, head). The program should be written in JAVA.arrow_forwardGoal 1: Update the Fractions Class Here we will overload two functions that will used by the Recipe class later: multipliedBy, dividedBy Previously, these functions took a Fraction object as a parameter. Now ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer (affecting numerator/denominator of the returned object). For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6. Goal 2: Update the Recipe Class The Recipe constructors so far did not specify how many servings the recipe is for. We will now add a private member variable of type int to denote the serving size and initialize it to 1. This means all recipes are initially constructed for a single serving. Update the overloaded extraction operator (<<) to include the serving size (see sample output below for an…arrow_forwardGoal 1: Update the Fractions Class Here we will overload two functions that will used by the Recipe class later: multipliedBy, dividedBy Previously, these functions took a Fraction object as a parameter. Now ADD an implementation that takes an integer as a parameter. The functionality remains the same: Instead of multiplying/dividing the current object with another Fraction, it multiplies/divides with an integer (affecting numerator/denominator of the returned object). For example; a fraction 2/3 when multiplied by 4 becomes 8/3. Similarly, a fraction 2/3 when divided by 4 becomes 1/6. Goal 2: Update the Recipe Class Now add a private member variable of type int to denote the serving size and initialize it to 1. This means all recipes are initially constructed for a single serving. Update the overloaded extraction operator (<<) to include the serving size (sample output below for an example of formatting) . New Member functions to the Recipe Class: 1. Add four member functions…arrow_forward
- Create a new class, called ConstantList that stores a "constant" list of integers (ints). Once created the list is fixed (none of the items can be changed, no items can be added or removed, the order is fixed). Use an array to store your list. Your class will have a single constructor that takes an array of ints as input that will be used to specify the constant list. You must provide appropriate methods to give the user of your class access to the list elements. A user should be able to access individual elements (by position) and the entire list of numbers. Your class must use encapsulation. Explain how your solutions solves the problem. That is, explain why your ConstantList really is a constant list of numbers.arrow_forwardCreate a class called Planet. A planet's state is it's name and a list (array) of moons that it has. You can assume there is a Moon class that a single constructor that takes it's name as input (a String). Add three constructors to your Planet class: Planet(String planetName) (planet has no moons)Planet(String planetName, String moonName) (planet has one moon)Planet(String planetName, Moon[] moons) (planet has arbitrary number of moons). Be sure to use constructor chaining. Question: When creating a planet object, what is the minimum number of constructors that are called (in total, either explicitly by you or by the JVM)? What is the maximum number of constructors that might be called (in total, either explicitly by you or by the JVM)? Give an example for each.arrow_forwardWrite 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_forward
- URGENtt!! 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_forwardWrite the source code of the class CrewMember. A crew member cannot change its duty type. For example, a hostess can never become a pilot. The number of years to become a senior member should be obtained from the class FlightRules. How can we write FlightRules class its enough for me?arrow_forwardCan someone help me write a class in Java. The class will read a file of people: their name, year of birth, and year of death. The class must have at least one ArrayList. The class's constructor will read the file specified by its parameter. Each line looks like the samplebelow:FirstName LastName YearOfBirth YearOfDeathThe items on each line are separated by tabs. The class will also have these methods: -preBoom() : This method will return the number of people born before 1945, the start ofthe Baby Boom - minAge() : This method will return the age of the youngest person in the list - maxAge() : This method will return the age of the oldest person in the list - aveAge() : This method will return the average age of the people in the list. Theaverage value returned will be an integer. - seniors() : This method will return the number of people aged 65 or overarrow_forward
- 1)The program should be written in JAVA. Create a "Car" class that keeps car ids and prices. And create a "Galleries" class that holds the car list for a particular gallery. In this class there should be methods for get / set and print for car name, car number and car list. Adding / Removing Cars to the List in This Class should have methods. And create another method to find and print the IDs of Cars with Car Segment equal to X. (print_id(X)). Car Prices are as follows according to the segments. 0$-19999$ -> Z20000$-29999$ -> Y30000$-44999$ -> T45000$-100000$ -> P Apply the Car list using "Singly Linked List"(Node, newNode, head).arrow_forwardWrite a java class Library for implementing a library application which accepts books into its list and user should be able to search books based on a book title or the Author. The books should be added to an ArrayList. Write the Main class with main function in it to display a menu to opt whether to add books, list books and search books. Use a constructor of Library class to add books. Use a method named searchTitle and searchAuthor in Library class to search the books. 1) Define class Library with required instance variable ArrayList for adding books 2) The Library class should have one constructor and three methods to do the below functions The Constructor needs to add books Method displayBook to List all the books in the library. Method named search Title to search books based on book title, this method should be able to accept a user string and search if a book with the title is in the added book list Method named searchAuthor to search books based on book title, this method…arrow_forwardThe play method in the Player class of the craps game plays an entire game without interaction with the user. Revise the Player class so that its user can make individual rolls of the dice and view the results after each roll. The Player class no longer accumulates a list of rolls, but saves the string representation of each roll after it is made. Add new methods rollDice, getNumberOfRolls, isWinner, and isLoser to the Player class. The last three methods allow the user to obtain the number of rolls and to determine whether there is a winner or a loser. The last two methods are associated with new Boolean instance variables (winner and loser respectively). Two other instance variables track the number of rolls and the string representation of the most recent roll (rollsCount and roll). Another instance variable (atStartup) tracks whether or not the first roll has occurred. At instantiation, the roll, rollsCount, atStartup, winner, and loser variables are set to their appropriate…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
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License