Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7.12, Problem 7.26CP
Write a structure declaration for a structure named Student that holds the following data about a student:
ID (int)
entry year (int)
GPA (double)
Then write definition statements that create the following two Student variables and initialize them using initialization lists.
Variable s1 should have ID number 1234, entry year 2008, and GPA 3.41.
Variable s2 should have ID number 5678 and entry year 2010. The GPA member should be left uninitialized.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a structure declaration for a structure named Student that holds the following data about a student:
ID (int)
entry year (int)
GPA (double)
Then write definition statements that create the following two Student variables and initialize them using initialization lists.Variable s1 should have ID number 1234, entry year 2008, and GPA 3.41. Variable s2 should have ID number 5678 and entry year 2010. The GPA member should be left uninitialized.
write an expression that can be used to access the structure members in each of the following parts:a) Member lastName of structure customerRecord.
Write a function that uses a Rectangle structure reference variable as its parameter and stores the user’s input in the structure’s members.
Use the following structure declaration to answer the question.struct Rectangle
{ int length; int width;};
Chapter 7 Solutions
Starting Out with C++: Early Objects (9th Edition)
Ch. 7.5 - Which of the following shows the correct use of...Ch. 7.5 - An objects private member variables can be...Ch. 7.5 - Assuming that soap is an instance of the Inventory...Ch. 7.5 - Complete the following code skeleton to declare a...Ch. 7.7 - Briefly describe the purpose of a constructor.Ch. 7.7 - Constructor functions have the same name as the A)...Ch. 7.7 - A constructor that requires no arguments is called...Ch. 7.7 - Assume the following is a constructor: ClassAct: :...Ch. 7.7 - Prob. 7.9CPCh. 7.7 - True or false: A class may have a constructor with...
Ch. 7.7 - A destructor function name always starts with A) a...Ch. 7.7 - True or false: Just as a class can have multiple...Ch. 7.7 - What will the following program code display on...Ch. 7.7 - What will the following program code display on...Ch. 7.9 - 7.15 private class member function can be called...Ch. 7.9 - When an object is passed to a function, a copy of...Ch. 7.9 - If a function receives an object as an argument...Ch. 7.9 - Prob. 7.18CPCh. 7.9 - Prob. 7.19CPCh. 7.10 - Prob. 7.20CPCh. 7.10 - Write a class declaration for a class named...Ch. 7.10 - Write a class declaration for a class named Pizza...Ch. 7.10 - Write four lines of code that might appear in a...Ch. 7.11 - Assume the following class components exist in a...Ch. 7.11 - What header files should be included in the client...Ch. 7.12 - Write a structure declaration for a structure...Ch. 7.12 - Prob. 7.27CPCh. 7.12 - Prob. 7.28CPCh. 7.12 - Write a declaration for a structure named...Ch. 7.12 - Write a declaration for a structure named City,...Ch. 7.12 - Write assignment statements that store the...Ch. 7.12 - Prob. 7.32CPCh. 7.12 - Write a function that uses a Rectangle structure...Ch. 7.12 - Prob. 7.34CPCh. 7.15 - Prob. 7.35CPCh. 7.15 - When designing an object -oriented application,...Ch. 7.15 - How do you identify the potential classes in a...Ch. 7.15 - What two questions should you ask to determine a...Ch. 7.15 - Look at the following description of a problem...Ch. 7 - Prob. 1RQECh. 7 - Which of the following must a programmer know...Ch. 7 - Prob. 3RQECh. 7 - ______programming is centered around functions, or...Ch. 7 - An object is a software entity that combines both...Ch. 7 - An object is a(n) ______ of a class.Ch. 7 - Prob. 7RQECh. 7 - Once a class is declared, how many objects can be...Ch. 7 - An objects data items are stored in its...Ch. 7 - The procedures, or functions, an object performs...Ch. 7 - Bundling together an objects data and procedures...Ch. 7 - An objects members can be declared public or...Ch. 7 - Normally a classs _________ are declared to be...Ch. 7 - A class member function that uses, but does not...Ch. 7 - A class member function that changes the value of...Ch. 7 - When a member functions body is written inside a...Ch. 7 - A class constructor is a member function with the...Ch. 7 - A constructor is automatically called when an...Ch. 7 - Constructors cannot have a(n) ______ type.Ch. 7 - A(n) ______ constructor is one that requires no...Ch. 7 - A destructor is a member function that is...Ch. 7 - A destructor has the same name as the class but is...Ch. 7 - A constructor whose parameters all have default...Ch. 7 - A class may have more than one constructor, as...Ch. 7 - Prob. 25RQECh. 7 - In general, it is considered good practice to have...Ch. 7 - When a member (unction forms part of the interface...Ch. 7 - When a member function performs a task internal to...Ch. 7 - True or false: A class object can be passed to a...Ch. 7 - Prob. 30RQECh. 7 - It is considered good programming practice to...Ch. 7 - If you were writing a class declaration for a...Ch. 7 - If you were writing the definitions for the Canine...Ch. 7 - A structure is like a class but normally only...Ch. 7 - By default, are the members of a structure public...Ch. 7 - Prob. 36RQECh. 7 - When a structure variable is created its members...Ch. 7 - Prob. 38RQECh. 7 - Prob. 39RQECh. 7 - Prob. 40RQECh. 7 - Prob. 41RQECh. 7 - Write a function called showReading. It should...Ch. 7 - Write a function called input Reading that has a...Ch. 7 - Write a function called getReading, which returns...Ch. 7 - Indicate whether each of the following enumerated...Ch. 7 - Prob. 46RQECh. 7 - Assume a class named Inventory keeps track of...Ch. 7 - Write a remove member function that accepts an...Ch. 7 - Prob. 49RQECh. 7 - A) struct TwoVals { int a, b; } ; int main() { }...Ch. 7 - A) struct Names { string first; string last; } ;...Ch. 7 - A) class Circle: { private double centerX; double...Ch. 7 - A) class DumbBell; { int weight; public: void set...Ch. 7 - If the items on the following list appeared in a...Ch. 7 - Look at the following description of a problem...Ch. 7 - Soft Skills Working in a team can often help...Ch. 7 - Date Design a class called Date that has integer...Ch. 7 - Report Heading Design a class called Heading that...Ch. 7 - Widget Factory Design a class for a widget...Ch. 7 - Car Class Write a class named Car that has the...Ch. 7 - Population In a population, the birth rate and...Ch. 7 - Gratuity Calculator Design a Tips class that...Ch. 7 - Inventory Class Design an Inventory class that can...Ch. 7 - Movie Data Write a program that uses a structure...Ch. 7 - Movie Profit Modify the Movie Data program written...Ch. 7 - Prob. 10PCCh. 7 - Prob. 11PCCh. 7 - Ups and Downs Write a program that displays the...Ch. 7 - Wrapping Ups and Downs Modify the program you...Ch. 7 - Left and Right Modify the program you wrote for...Ch. 7 - Moving Inchworm Write a program that displays an...Ch. 7 - Coin Toss Simulator Write a class named Coin. The...Ch. 7 - Tossing Coins for a Dollar Create a game program...Ch. 7 - Fishing Came Simulation Write a program that...Ch. 7 - Group Project 19. Patient Fees This program should...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain why the rapid delivery and deployment of new systems is often more important to businesses than the det...
Software Engineering (10th Edition)
Indexing can clearly be very beneficial. Why should you not create an index for every column of every table of ...
Modern Database Management (12th Edition)
Any piece of data that is stored in a computers memory must be stored as a binary number.
Starting out with Visual C# (4th Edition)
A function in Python can return more than one value.
Starting Out with Python (4th Edition)
What will the following code display? For number in range (6): Print (number)
Starting Out with Python (3rd Edition)
Circumference and Area of a Circle) Heres a peek ahead. In this chapter, you learned about integers and the typ...
Java How To Program (Early Objects)
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
- 3. Create 3 structures student, marks and university.Student should have name semester and grade.University should have student as its member and 1 more member need to be adress.Cin all the values and display them on screen. You can use member function of structure or you can directly display them by accessing separately.arrow_forwardSuppose that structures and variable p are declared as follows: struct new_struct{ char a; int b[10]; }; struct new_struct s; Which one of the following statements will update the 3rd element of b in the structure s to 34? s.b= 34; s.b[2] =34;arrow_forwardx = apple .code; set the value of code data member in the structure object apple to be equal to x assign the value of the data O member code in the structure object apple to the variable x compare the value of x to the value of data member apple.code multiply apple by code and assign the result to the variable xarrow_forward
- The member variables in a structure can have different data types.a. True b. Falsearrow_forwardMark the following statements as true or false. All members of a struct must be of different types. (1) A struct is a definition, not a declaration. (1) A struct variable must be declared after the struct definition. (1) A struct member is accessed by using the operator :. (2) The only allowable operations on a struct are assignment and member selection. (2) Because a struct has a finite number of components, relational operations are allowed on a struct. (2) Some aggregate input/output operations are allowed on a struct variable. (2) A struct variable can be passed as a parameter either by value or by reference. (4) A function cannot return a value of the type struct. (4) An array can be a member of a struct. (6, 7) A member of a struct can be another struct. (8)arrow_forwardAssume the pointer you defined in question 10.18 points to a valid Rectangle structure. Write the statement that displays the structure’s members through the pointer. Assume the following structure declaration exists struct Rectangle { int length; int width; };arrow_forward
- An Inventory structure is declared as follows: struct Inventory{int itemCode; int qtyOnHand;}; Write a definition statement that creates an Inventory variable named trivet and initializes it with an initialization list so that its code is 555 and its quantity is110.arrow_forwardneed code in C++ answer all parts Assume the Product structure is declared as follows: struct Product{string description; // Product descriptionint partNum; // Part numberdouble cost; // Product cost};1. Add two constructors to the Product structure declaration. The firstshould be a default constructor that sets the description member to the null string and the partNum and cost members to zero. The second con-structor should have three parameters: a string, an int, and a double. It should copy the values of the arguments into the description, partNum,and cost members.2. Define a print function as member of the struct that prints an object ofthis struct in the following format.Description: Claw Hammer PartNumber: 547Part Cost: $8.293. Declare an array of size 5 with pointers and named it ”items”. Initilize itwith user input values.4. Write a print function (not as a member of the struct) and pass a pointerto the pointer that points to the array(double pointer) and print all theitems of…arrow_forwardc++ data structurearrow_forward
- write an expression that can be used to access the structure members in each of the following parts: d) Member firstName of the structure pointed to by customerPtr.arrow_forwardQ5: Write a C++ program that uses a structure to store records of cars. A car record contains seating_capacity (integer), model_year (string), car_type(String), and Engine_type as Eng. (Engine). The field Engine_type is of type Engine, a separately declared structure that contains three fields Capacity(int) in CC, Power (int) in horsepower, and No_of_cylenters(int). Now in main function you are required to declare a car C1, take input from user, for car_type, model_year, and car_type, Capicity, and show it as an output.Sample Input:Please enter car_type C1: Toyota SedanPlease enter model year for Toyota Sedan: 2020Please enter capacity for Toyota Sedan 2020: 1300Please enter power for Toyota Sedan: 200Sample Output:Toyota Sedan model 2020 is 1300 cc with 150 horsepowerarrow_forwardWrite a structure declaration for a structure named Account that holds the following data about a savings account. Include a constructor that allows data values to be passed in for all four members. Account number (string) Account balance (double) Interest rate (double) Average monthly balance (double) Now write a definition statement for an Account variable that initializes the members with the following data:Account number: ACZ42137 Account balance: $4512.59 Interest rate: 4% Average monthly balance: $4217.07arrow_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
Structured Chart; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=vdUO-sGA1DA;License: Standard YouTube License, CC-BY
Introduction to Structure Charts; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=QN2bjNplGlQ;License: Standard Youtube License