Starting Out with C++: Early Objects (9th Edition)
Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 7, Problem 46RQE
Program Plan Intro

A)

Enumeration:

Enumeration is a user-defined data type which consists of enumerators; the enumerators are used to represent integer constants.

  • An enumeration can be defined by using the keyword “enum”.
  • By default, the values of enumeration type are filled with “0” to “n” sequentially and those default values can be changed when declaring the enumeration.
    • In a sequence of enumerators, if the first enumerator is assigned with a “user-defined value” and the next enumerator is not assigned with any value, then by default the next enumerator will be filled by the value “user-defined value of previous enumerator plus 1”.
  • The type name of an enumeration is optional; if name of the enumeration type is not given then it is referred as “anonymous”.

Syntax:

Syntax to declare an enumerated data type is as follows,

enum type_name {identifier_1, identifier_2, identifier_3, … identifier_n};

In the above syntax,

  • “enum” is the keyword used to declare an enumerator.
  • “type_name” refers the name of the type of the enumerator.

“identier_1” to “identifier_n” are refers the list of the identifiers declared in the enumerator.

Given statement:

enum Department {Purchasing, Manufacturing, Warehouse, Sales};

Department floor1, floor2;

int dNum = 2;

  • Here, an “enum” is a keyword and “Department” is the variable name of an enumeration. “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are the values used in the enumeration.
  • The variable name “floor1” and “floor2” of type “Department” is defined. These two variables can only store any one of the four values (Purchasing, Manufacturing, Warehouse, Sales).
  • “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are treated as integers by complier.
  • Once enumerators are defined, their value cannot be changed in program.

Program Plan Intro

B)

Enumeration:

Enumeration is a user-defined data type which consists of enumerators; the enumerators are used to represent integer constants.

  • An enumeration can be defined by using the keyword “enum”.
  • By default, the values of enumeration type are filled with “0” to “n” sequentially and those default values can be changed when declaring the enumeration.
    • In a sequence of enumerators, if the first enumerator is assigned with a “user-defined value” and the next enumerator is not assigned with any value, then by default the next enumerator will be filled by the value “user-defined value of previous enumerator plus 1”.
  • The type name of an enumeration is optional; if name of the enumeration type is not given then it is referred as “anonymous”.

Syntax:

Syntax to declare an enumerated data type is as follows,

enum type_name {identifier_1, identifier_2, identifier_3, … identifier_n};

In the above syntax,

  • “enum” is the keyword used to declare an enumerator.
  • “type_name” refers the name of the type of the enumerator.

“identier_1” to “identifier_n” are refers the list of the identifiers declared in the enumerator.

Given statement:

enum Department {Purchasing, Manufacturing, Warehouse, Sales};

Department floor1, floor2;

int dNum = 2;

  • Here, an “enum” is a keyword and “Department” is the variable name of an enumeration. “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are the values used in the enumeration.
  • The variable name “floor1” and “floor2” of type “Department” is defined. These two variables can only store any one of the four values (Purchasing, Manufacturing, Warehouse, Sales).
  • “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are treated as integers by complier.
  • Once enumerators are defined, their value cannot be changed in program.

Program Plan Intro

C)

Enumeration:

Enumeration is a user-defined data type which consists of enumerators; the enumerators are used to represent integer constants.

  • An enumeration can be defined by using the keyword “enum”.
  • By default, the values of enumeration type are filled with “0” to “n” sequentially and those default values can be changed when declaring the enumeration.
    • In a sequence of enumerators, if the first enumerator is assigned with a “user-defined value” and the next enumerator is not assigned with any value, then by default the next enumerator will be filled by the value “user-defined value of previous enumerator plus 1”.
  • The type name of an enumeration is optional; if name of the enumeration type is not given then it is referred as “anonymous”.

Syntax:

Syntax to declare an enumerated data type is as follows,

enum type_name {identifier_1, identifier_2, identifier_3, … identifier_n};

In the above syntax,

  • “enum” is the keyword used to declare an enumerator.
  • “type_name” refers the name of the type of the enumerator.

“identier_1” to “identifier_n” are refers the list of the identifiers declared in the enumerator.

Given statement:

enum Department {Purchasing, Manufacturing, Warehouse, Sales};

Department floor1, floor2;

int dNum = 2;

  • Here, an “enum” is a keyword and “Department” is the variable name of an enumeration. “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are the values used in the enumeration.
  • The variable name “floor1” and “floor2” of type “Department” is defined. These two variables can only store any one of the four values (Purchasing, Manufacturing, Warehouse, Sales).
  • “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are treated as integers by complier.
  • Once enumerators are defined, their value cannot be changed in program.

Program Plan Intro

D)

Enumeration:

Enumeration is a user-defined data type which consists of enumerators; the enumerators are used to represent integer constants.

  • An enumeration can be defined by using the keyword “enum”.
  • By default, the values of enumeration type are filled with “0” to “n” sequentially and those default values can be changed when declaring the enumeration.
    • In a sequence of enumerators, if the first enumerator is assigned with a “user-defined value” and the next enumerator is not assigned with any value, then by default the next enumerator will be filled by the value “user-defined value of previous enumerator plus 1”.
  • The type name of an enumeration is optional; if name of the enumeration type is not given then it is referred as “anonymous”.

Syntax:

Syntax to declare an enumerated data type is as follows,

enum type_name {identifier_1, identifier_2, identifier_3, … identifier_n};

In the above syntax,

  • “enum” is the keyword used to declare an enumerator.
  • “type_name” refers the name of the type of the enumerator.

“identier_1” to “identifier_n” are refers the list of the identifiers declared in the enumerator.

Given statement:

enum Department {Purchasing, Manufacturing, Warehouse, Sales};

Department floor1, floor2;

int dNum = 2;

  • Here, an “enum” is a keyword and “Department” is the variable name of an enumeration. “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are the values used in the enumeration.
  • The variable name “floor1” and “floor2” of type “Department” is defined. These two variables can only store any one of the four values (Purchasing, Manufacturing, Warehouse, Sales).
  • “Purchasing”, “Manufacturing”, “Warehouse” and “Sales” are treated as integers by complier.
  • Once enumerators are defined, their value cannot be changed in program.

Blurred answer
Students have asked these similar questions
Define a struct computerType to store the following details about a computer: manufacturer (string), model type (string), processor type (string), ram (int), hard drive size (int), year when the computer was built (int), and the price (double). Write a program that declares a variable of type computerType, prompts the user to input data about a computer, and output the computer’s data. Your program should use the string functions. c++ program
SUBJECT: PROGRAMMING FUNDAMENTELS LAB IT provides best solutions for manual work that makes life easier .Suppose a university wants to manage its data in the form of software. Being a programmer you have been asked to create the following structures in C. 1. Student: a. Name b. RegId c. Enrolled courses (Labs + Theory) d. Department e. Semester2. Faculty: a. Name b. Department c. Designation d. Salary:Implement the following scenario using functions:  setMarks(): This function will allow faculty members to set Student marks. getGpa(): Takes students as an argument and calculates the student’s GPA. displayStudent(): display the given student’s information. displayFaculty(): display the given faculty’s information. NOTE ; KINDLY PROVIDE THE ANSWER OF THIS QUESTION IN C LANGUAGE ASAP
PROGRAMMING LANGUAGE: C++   Write a complete C++ program with the following features.a. Declare a class Time with two fields, hour and minute.b. Provide appropriate constructors to initialize the data members.c. Overload the pre and postfix increment operators (using memberfunctions) to increment the minutes by one. Also make sure if m inutes are59 and you increment the Time it should update hours and minutesaccordingly.d. Provide a function display() to display the hours and minutes.e. In main(), create objects of Time, initialize them using constructors andcall the display functions.f. Test the following in your main:a. T3= ++T1;b. T4=T2++;

Chapter 7 Solutions

Starting Out with C++: Early Objects (9th Edition)

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
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr