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 39RQE
Program Plan Intro
Structure:
In C++, the structure is a user-defined data type, which contains different type of elements with different lengths.
- The size of the structure is calculated by the total number of elements which is declared in a structure.
- The “struct” keyword is used instead of the “class” keyword.
- Normally, structure declaration only declares member variables and does not contain any member functions.
- Structure declaration does not include any access specifiers like public or private.
- In default, structure member variables are declared as public.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include
#include
#include "Product.h"
using namespace std;
int main() {
vector productList;
Product currProduct;
int currPrice;
string currName;
unsigned int i;
Product resultProduct;
cin>> currPrice;
while (currPrice > 0) {
}
cin>> currPrice;
main.cpp
cin>> currName;
currProduct.SetPriceAndName (currPrice, currName);
productList.push_back(currProduct);
resultProduct = productList.at (0);
for (i = 0; i < productList.size(); ++i) {
Type the program's output
Product.h
1
CSE Scanned
Product.cpp
if (productList.at (i).GetPrice () < resultProduct.GetPrice ()) {
resultProduct = productList.at(i);
}
AM
cout << "$" << resultProduct.GetPrice() << " " << resultProduct. GetName() << endl;
return 0;
Input
10 Cheese
6 Foil
7 Socks
-1
Output
Screen Output
#include
#include
#define MAX 3
typedef struct
{
char part[20];
int quantity;
float price;
}partsRecord;
void myParts (void);
void printBin(partsRecord *recBin);
int main(void)
{
myParts();
return(0);
}
void myParts (void)
{
partsRecord Bin[MAX] = { { "Resistor", 300, 0.05 },
{ "Capacitor", 250, 1.03 },
{ "Inductor", 123, 0.65 }};
int index;
for (index
{
0; index part, recBin->quantity, recBin->price);
return;
}
2c) What type of argument is passed to the printBin function?
#include <iostream>#include <string>#include <iomanip>using namespace std;// structurestruct Hat{string brand;string color;float price;};// Customer structurestruct Customer{string fullName ;int age ;Hat hat; // Hat structure (nested in Customer)};int main(){// declare 5 variables of CustomerCustomer customer_1,customer_2,customer_3,customer_4,customer_5;cout<<"Welcome to Hats For U!\n";cout<<"Customer 1\n";cout<<"Enter customer's Full Name: ";getline(cin,customer_1.fullName);cout<<"Enter customer's age: ";cin>>customer_1.age;cout<<"Enter the brand of hat: ";cin>>customer_1.hat.brand;cout<<"Enter the hat color: ";cin>>customer_1.hat.color;cout<<"Enter the hat price(RM): ";cin>>customer_1.hat.price;
cout<<"Hat 2\n";cout<<"Enter customer's Full Name: ";getline(cin,customer_2.fullName);getline(cin,customer_2.fullName);cout<<"Enter customer's age:…
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
- Define a struct type that represents an exercise plan. The struct should store the following data: plan name (a character array of size 50) and goal calories to burn (an integer). The type should be renamed from struct exercise_plan to Exercise_plan.arrow_forwardC code Blocks Select all of the code segments that are the correct way to define a variable class as an array of 185 personal structures. struct personal { int id; // id numberchar name[80];}; Options: a .personal class[185]; b. struct personal class[185]; c. typedef struct personal classStruct;classStruct class[185]; d. typedef class[185];arrow_forwardFind errors / syntax error. Write line numberarrow_forward
- The terms "data member" and "local variable" refer to two different kinds of variables.arrow_forward== include using namespace std; # int main () { int a = 14; do { if( a 15) { a = a + 1; } cout << a <<" "; a = a + 1; } while( a < 16 ); } الجواب: إجابةarrow_forwardProgram Name: <LastNameFirstInit>_PetShelter You work at a Pet Shelter that take in homeless pets. You have been tasked with creating a report that shows a list of all the dog breeds currently staying at the shelter. This list should include the breed name along with the count for each breedcurrently being housed at the shelter. In addition, at the end, the report should display the name of breed that we have the most (max) of currently at the shelter. In addition, your program should utilize methods for building the report and searching for the max breed count. Two parallel arrays have been provided. You can use the following code to get you started. //START CUTTING CODE HERE public class MichakR_PetShelter { public static void main(String[] args) { String[] breedNames = {"Bulldog", "German Shepherd", "Golden Retriever", "Beagle", "Poodle", "Boxer", "Mixed Dog", "Husky"}; int[] breedCounts = {2,5,3,1,8,1,11, 3}; //generate report //get Max Breed //print report } public…arrow_forward
- Fraction.h: #ifndef _FRACTION_H#define _FRACTION_H#include <iostream>using namespace std;class Fraction{int num;int den;public:Fraction();Fraction(int n);Fraction(int n, int d);void reduce();int GetNum()const;int GetDen()const;void SetNum(int n);void SetDen(int d);Fraction operator+(const Fraction&)const;Fraction operator-(const Fraction&)const;Fraction operator*(const Fraction&)const;Fraction operator/(const Fraction&)const;Fraction operator++();Fraction operator++(int);friend Fraction operator--(Fraction&);friend Fraction operator--(Fraction&, int);friend ostream& operator<<(ostream&, const Fraction&);friend istream& operator>>(istream&, Fraction&);friend bool isExact(const Fraction&, const Fraction&); //checks exact valuesfriend bool operator == (const Fraction&, const Fraction&);//checks equivalencyfriend bool operator < (const Fraction&, const Fraction&);friend bool operator > (const…arrow_forwardexplain answerarrow_forwardFill in the blanksarrow_forward
- 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.arrow_forward#include <stdio.h>#include<stdlib.h>struct Distance{int feet;float inch;} dist1, dist2, sum;int main(){struct Distance* distance1 = NULL; struct Distance* distance2 = NULL; struct Distance* distance3 = NULL; distance1 = (struct Distance*)malloc(sizeof(struct Distance*));distance2 = (struct Distance*)malloc(sizeof(struct Distance*));distance3 = (struct Distance*)malloc(sizeof(struct Distance*));printf("input feet for distance no.1:");scanf("%d", &distance1->feet); printf("input inch for distance no.1:");scanf("%f", &distance1->inch); printf("input feet for distance no.2:");scanf("%d", &distance2->feet); printf("input inch for distance no.2:");scanf("%f", &distance2->inch); printf("input feet for distance no.3:");scanf("%d", &distance3->feet); printf("input inch for distance no.3:");scanf("%f", &distance3->inch); printf("1st distance\n");printf("Enter feet: ");scanf("%d", &dist1.feet); printf("Enter inch: ");scanf("%f",…arrow_forwardin c language typedef _people { int age; char name[ 32 ] ; } People_T ; People_T data [ 3 ]; Using string lib function, Assign 30 and Cathy to the first cell, Assign 40 and John to the second cell and Assign 50 and Tom to the third cellarrow_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 PtrEBK 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
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT