Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 7, Problem 41RQE
Program Plan Intro
Structure:
- Structure is a “user-defined” data type.
- To use structure variables in the
programming language, it is important to declare the structure. - Member variables are declared inside the structure.
- Members can be accessed with the structure name or structure object.
- Name of the structure name is also called as “tag”. It is declared before variable declaration.
- Variables can be accessed with the help of a “tag”.
Syntax:
struct structure_Name
{
//variable declarations;
}structure_Object;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C++
Given a structure named Telco4G as follows
struct Telco4G
{
string telcoProvider; // name of the provider i.e. TelcoA
// number of customers
// amount of unpaid bills in RM
int totalUser;
int overdueBills;
};
(a) Using struct Telco4G, initialize the structure variable telcol based on the
following information:
• TelcoA is the telco provider
• 2 million number of users
Unpaid bills are RM 3.56 million
Then, write the syntax to print/display the totalUser structure member in the struct
variable Telco4G.
Create a structure called BarcelonaPlayer with the following members.struct BarcelonaPlayer{char name[20];int age;char country[20];char Position[20];double Salary;double Rating;};
Chapter 7 Solutions
Starting Out With C++: Early Objects (10th 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...
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
- Declare a data structure marks_t, which contains the following type int members: int attendance //0 to 5 int active //0 to 5 int quiz_1 //0 to 5 int quiz_2 //0 to 5 int midExam //0 to 20 int finalExam //0 to 60arrow_forwardIn C++arrow_forwardUsing C++ Create a program Customer Name (string) Account Number(integer) Account Type(string) Account Balance(double) Create structure objects to hold the structure information for at least 2 customers Print the customer information from the structure Enter the Customer's Name: Bill Enter the Account Number: 1234 Enter the Account Type: Checking Enter the Account Balance: $1250.00 Enter the Customer's Name: Jane Enter the Account Number: 1256 Enter the Account Type: Savings Enter the Account Balance: $2540.00 Here is the Customer Account data: Customer 1 Name: Bill Account number: 1234 Account Type: Checking Account Balance: #1250.00 ******************************** Customer 2 Name: Jane Account number: 1256 Account Type: Savings Account Balance: $2540.00 ********************************arrow_forward
- Write a program that uses a structure named MovieData to store the following information about a movie: TitleDirectorYear ReleasedRunning time (in minutes)Include a constructor that allows all four of these member data values to be specified at the time a MovieData variable is created. The program should create two MovieData variables and pass each one in turn to a function that displays the information about the movie in a clearly formatted manner. Pass the MovieData variables to the display function by value.arrow_forwardCS 116 – Programming Fundamentals for Computer Science Lab #3D Objectives To learn to code, compile and run a program containing SELECTION structures Assignment Plan and code a program utilizing one or more selection structures to solve the following problem: Write a program for Pentagon Parking Lot for all customers that use the lot during the day. Charges for vehicles are based upon the following rates: Cars: First 2 hours Free Next 3 hours $1.00 per hour Next 11 hours $0.50 per hour Trucks: First 2 hours Free Next 2 hours $2.00 per hour Next 12 hours $1.00 per hour Senior Citizens: No charge Have the user enter a character designation for rate of charge (C, T, S), the total time parked entered separately in hours and minutes. Determine the total number of hours (any minutes over 30 are to be counted as a full hour). A car may not be parked more than 16 hours. Compute the appropriate charge and print out a ticket for each customer. Be sure to check for invalid data…arrow_forwardIn C programming Create a structure called Car with the fields string brand int speed in km/hr. Create a function timeCar that accepts a Car type of parameter and a distance in km. Return the time needed for the car to reach the distance in minutes. In the main function, create a Car instance called car1 and ask the user to input the details for the car1's brand and speed. Also ask for an integer input, distance, then call the timeCar function while passing in the car1 instance and the inputted value of distance. Print the return value and interpolate it in this sentence: "It will take a Lopus car [ time_in_minutes ] minutes to reach a distance of [ distance ] ." Input 1. One line containing a string brand 2. One line containing an integer speed in km/hr 3. One line containing an integer distance in km Output Enter brand: Lopus Enter speed: 70 Enter distance: 140 It will take a Lopus car 120 minutes to reach a distance of 140.arrow_forward
- Q 1: A company named ABC hired three employees in different years; each employee gets an increment of 5000 yearly. Also each employee gets bonus amount of 10k for each project he has done yearly. The programs should have following attributes that should be entered by the user according to their need in specific parts: Employee name Served years No of projects done per year Initial salary Declare a structure for an employee, mention the attributes (name, no of years served, salary), declare an array of structures for no of employees. Then declare three functions, one should return a structure by value with no argument passed which will take all attributes from the user and in second pass the structure by reference as an argument to a function and it should display all the attributes of an employees and then in third pass the structure by value as an argument to a function and it should display current salary of employees.arrow_forwardC++ OOP PART 1: A phone number, such as (212) 767-8900, can be thought of as having three parts: the area code(212), the exchange (767), and the number (8900). Write a program that uses a structure to store thesethree parts of a phone number separately. Call the structure phone. Create two structure variables of typephone. Initialize one, and have the user input a number for the other one. Then display both numbers.The interchange might look like this: Enter your area code, exchange, and number: 415 555 1212 My number is (212) 767-8900 Your number is (415) 555-1212PART 2: Differentiate between deep and shallow copy with suitable code.arrow_forwardUsing c++ language !!!! Customer Name (string) Account Number(integer) Account Type(string) Account Balance(double) Create structure objects to hold the structure information for at least 2 customers Print the customer information from the structure Enter the Customer's Name: Bill Enter the Account Number: 1234 Enter the Account Type: Checking Enter the Account Balance: $1250.00 Enter the Customer's Name: Jane Enter the Account Number: 1256 Enter the Account Type: Savings Enter the Account Balance: $2540.00 Here is the Customer Account data: Customer 1 Name: Bill Account number: 1234 Account Type: Checking Account Balance: #1250.00 ******************************** Customer 2 Name: Jane Account number: 1256 Account Type: Savings Account Balance: $2540.00 ********************************arrow_forward
- Write a program Declare a data structure marks_t, which contains the following type int members: int attendance //0 to 5 int active //0 to 5 int quiz_1 //0 to 5 int quiz_2 //0 to 5 int midExam //0 to 20 int finalExam //0 to 60arrow_forwardRestaurant: Point-of-Sales System Create a software application that can be used for a Restaurant using C language. The expected minimum functionality are as follows: Menu Display It must display at least 10 choices with their corresponding prices On your menu, at least one of the categories/choice should have customization/add-on. You should have at least 3 customization/add-on (e.g. In Starbucks, you can have extra espresso shot). Taking Orders As a customer, I want to select which of the choices I want to order As a customer, everytime I specify select my choice, I want to specify the quantity of my selected choice. After I finished my order, it should ask, "Anything Else?". Afterwards, as a customer, I should be to enter my succeeding choice. In order to stop taking order, the exit should be part of the menu. As a customer, I would only select that choice to exit If the customer selects a choice qualified for customization, after specifying the quantity, I should be asked,…arrow_forwardRead the code shown below carefully and pick what can be printed? a = {"Craig":10, "Sizwe":20} print a A) Craig:10,Sizwe:20 B) SyntaxError C) {"Craig":10, "Sizwe":20} D) "Craig":10, "Sizwe":20arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author: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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,