Starting Out with C++: Early Objects
8th Edition
ISBN: 9780133360929
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 7.12, Problem 7.28CP
Explanation of Solution
Modified program:
The program is to get the input from the user and the structure hold this information then finally display the output.
//include the required header file
#include <iostream>
#include <string>
using namespace std;
//structure definition
struct MovieInfo
{
//declare the required variables
string name, director;
int year;
};
//main method definition
int main()
{
//Create an object for the structure
MovieInfo m;
//get the name of the movie from the user
cout << "Enter the following information about your "
<< "favorite movie . \n" << "Name: ";
getline(cin, m.name);
//get the director name from the user
cout << "Director: ";
getline(cin, m...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C++ please
NB: You will use only structure variable to solve this problem. You are discouraged to use array of structure.
struct gameType
{
string title;
int numPlayers;
bool online;
};
gameType Awesome[50];
Write the C++ statement that sets the first [0] title of Awesome to Best.
Chapter 7 Solutions
Starting Out with C++: Early Objects
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 - Prob. 45RQECh. 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 - Group Project 19. Patient Fees This program should...
Knowledge Booster
Similar questions
- . T F: A structure may hold variables of different data typesarrow_forwardIn C++ struct gameType { string title; int numPlayers; bool online; }; gameType Awesome[50]; Write the C++ Write the C++ statements that correctly initialize the online value of each game in Awesome to 1.arrow_forward#include <iostream> #include <string> #include <iomanip> using namespace std;// This program demonstrates partially initialized structure variables// PLACE YOUR NAME HEREstruct taxPayer {string name;long socialSecNum; float taxRate; float income; float taxes;};int main() { // Fill in code to initialize a structure variable named citizen1 so that// the first three members are initialized. Assume the name is Tim// McGuiness, the social security number is 255871234, and the tax rate is .35// Fill in code to initialize a structure variable named citizen2 so that // the first three members are initialized. Assume the name is John Kane, // the social security number is 278990582, and the tax rate is .29cout << fixed << showpoint << setprecision(2);// calculate taxes due for citizen1// Fill in code to prompt the user to enter this year's income for the citizen1 // Fill in code to read in this income to the appropriate structure member// Fill in code to…arrow_forward
- Using 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_forwardTrue or False You can compare enumerators and enum variables with relational operators.arrow_forwardLetter GradesWrite a program in C++ that translates a letter grade into a number grade. Letter grades areOperator Description Syntax Example+ Adds two numbers a + b 15 + 5 = 20- Subtracts two numbers a - b 15 - 5 = 20* Multiplies a * b 15 * 5 = 75/ Divides Numbers a / b 15 / 3 = 3A, B, C, D, and F, possibly followed by + or –. Their numeric values are 4, 3, 2, 1,and 0. There is no F+ or F–. A + increases the numeric value by 0.3, a – decreases itby 0.3. However, an A+ has value 4.0.Enter a letter grade: BThe numeric value is 2.7.arrow_forward
- C++arrow_forwardQ1) Write a program that use structure called car contains information about car these information are: 1) Car name. 2) Car ID. 3) Car model. 4) Engine size.arrow_forward#include <iostream>#include <string>#include <iomanip>using namespace std;// structurestruct Hat{string size;string color;float price;};// declare the structure variable int main(){Hat hat_1,hat_2,hat_3,hat_4,hat_5; cout<<"Welcome to Hats For U!\n";cout<<"Hat 1\n";cout<<"Enter the hat size: ";cin>>hat_1.size;cout<<"Enter the hat color: ";cin>>hat_1.color;cout<<"Enter hat price: ";cin>>hat_1.price; cout<<"Hat 2\n";cout<<"Enter the hat size: ";cin>>hat_2.size;cout<<"Enter the hat color: ";cin>>hat_2.color;cout<<"Enter hat price: ";cin>>hat_2.price; cout<<"Hat 3\n";cout<<"Enter the hat size: ";cin>>hat_3.size;cout<<"Enter the hat color: ";cin>>hat_3.color;cout<<"Enter hat price: ";cin>>hat_3.price; cout<<"Hat 4\n";cout<<"Enter the hat size: ";cin>>hat_4.size;cout<<"Enter the hat color:…arrow_forward
- C PROGRAMMING - STRUCTURE DEFINITION AND DECLARATION LESSON Declare an array of structures with 12 elements. Each element is a structure with three fields. The first field shows the month in numeric form (1 to 12). The second field shows the name of the moth. The third field shows the number of days in the month.arrow_forwardC++ code screenshot and output is mustarrow_forwardC++ program #include<iostream> #include<fstream> #include<string> using namespace std; const int NAME_SIZE = 20; const int STREET_SIZE = 30; const int CITY_SIZE = 20; const int STATE_CODE_SIZE = 3; struct Customers { long customerNumber; char name[NAME_SIZE]; char streetAddress_1[STREET_SIZE]; char streetAddress_2[STREET_SIZE]; char city[CITY_SIZE]; char state[STATE_CODE_SIZE]; int zipCode; char isDeleted; char newLine; }; void add_data(int no_of_records, ofstream& fout) { struct Customers c; cout << "Enter the Customer data:" << endl; cout << "Name:"; cin >> c.name; cout << "Street Address 1:"; cin >> c.streetAddress_1; cout << "Street Address 2:"; cin >> c.streetAddress_2; cout << "City:"; cin >> c.city; cout << "State:"; cin >> c.state; cout << "Zip Code:"; cin >> c.zipCode; cout << endl; c.customerNumber = no_of_records; c.isDeleted = 'N'; c.newLine = '\n'; cout…arrow_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
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