how you would declare a variable in the main function of the

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

how how you would declare a variable in the main function of the Jigsaw type using the initializing constructor to give it a piece count of 1000 and the dimensions in the my dimensions array. Then show how to call the getVolume function Print the resulting volume

 

BE SURE TO ANSWER ALL PARTS OF THE QUESTION
(i) Suppose a C++ class is needed to represent a jigs
Time left 0:38
computer program. The class should be named Jigsaw and has tw
member variables for a piece_count (a positive integer) and
dimensions (a 1D array of three floating-point values). For
example, a jigsaw puzzle might have a piece count of 1000 and the
dimensions array might contain 1.7, 19.3, and 21.0. Write a
declaration for this class using the most suitable data types. Declare
a default constructor and an initializing constructor (with one
parameter for each member variable). The constructors should be
available outside the class but the variables should not be.
(ii) Write the implementation for a member function named
getVolume in the Jigsaw class that returns the volume, which is
obtained by multiplying the three numbers in the dimensions array.
Use the most suitable return type for the function. The function
should remain constant.
(iii) Assume an array named my dimensions containing three
floating-point values has been declared and initialized to 1.7, 19.3,
and 21.0. Show how you would declare a variable in the main
function of the Jigsaw type using the initializing constructor to
give it a piece count of 1000 and the dimensions in the
my_dimensions array.
Then show how to call the getVolume function. Print the resulting
volume.
Transcribed Image Text:BE SURE TO ANSWER ALL PARTS OF THE QUESTION (i) Suppose a C++ class is needed to represent a jigs Time left 0:38 computer program. The class should be named Jigsaw and has tw member variables for a piece_count (a positive integer) and dimensions (a 1D array of three floating-point values). For example, a jigsaw puzzle might have a piece count of 1000 and the dimensions array might contain 1.7, 19.3, and 21.0. Write a declaration for this class using the most suitable data types. Declare a default constructor and an initializing constructor (with one parameter for each member variable). The constructors should be available outside the class but the variables should not be. (ii) Write the implementation for a member function named getVolume in the Jigsaw class that returns the volume, which is obtained by multiplying the three numbers in the dimensions array. Use the most suitable return type for the function. The function should remain constant. (iii) Assume an array named my dimensions containing three floating-point values has been declared and initialized to 1.7, 19.3, and 21.0. Show how you would declare a variable in the main function of the Jigsaw type using the initializing constructor to give it a piece count of 1000 and the dimensions in the my_dimensions array. Then show how to call the getVolume function. Print the resulting volume.
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY