SlideShare ist ein Scribd-Unternehmen logo
1 von 3
HELPIDO.COM
CLICK HERE TO GET THE SOLUTION !!!!!!



COMP/220 iLab 6 of 7 - C++ Course

iLab 6 of 7: Overloaded Operators

iLAB OVERVIEW

Scenario and Summary

This lab is to introduce students to the concept of operator overloading as member functions of a
class. This will be done in the context of creating a class that will perform four basic mathematical
operations on complex numbers.

The C++ compiler has defined operators for all the arithmetic and assignment operations for its
native data types, such as integer, float, double, and so forth. However, for user-defined data types,
such as classes and structures, these operations are undefined.

C++ allows the programmer to create new definitions for these operators so that they can operate
specifically on these user-defined data types. Which set of operators is actually called and
implemented is decided during the compilation, and it is based on the data types of the operands
involved in the operation.

The ability to define a new set of data-type, dependent operations on existing operators, or
functions, is called operator overloading.



Deliverables



1.       Submit a single Notepad file containing the source code for all files of the lab to the Week
5 Dropbox. Your source code should use proper indentation and be error free. Be sure that your last
name and the lab number are part of the file name: for example, YourLastName_Lab5.txt.



Each program should include a comment section that includes, at a minimum, your name, the lab
and exercise number, and a description of what the program accomplishes.

2.       Submit a lab report (a Word document) containing the following information to the Week
6 Dropbox.

o         Include your name and the lab or lab exercise number.

o          Specification: Include a brief description of what the program accomplishes, including its
input, key processes, and output.
o          Test Plan: Include a brief description of the method you used to confirm that your
program worked properly. If necessary, include a clearly labeled table with test cases, predicted
results, and actual results.

o         Summary and Conclusions: Write a statement summarizing your predicted and actual
output, and identify and explain any differences. For conclusions, write at least one nontrivial
paragraph that explains, in detail, either a significant problem you had and how you solved it or, if
you had no significant problems, something you learned by doing the exercise.

o         A UML diagram: This should show all the classes, class members, access specifiers, data
types, and function arguments, along with any and all class-to-class relationships.

o          Answers to Lab Questions: Include the answers to any and all lab questions asked in the
lab steps.

Each lab exercise should have a separate section in the lab-report document.

Your lab grade is based upon

1.        the formatting of your source code;

2.        the use of meaningful identifiers;

3.        the extent of internal documentation;

4.        the degree to which an exercises’ specifications are met; and

5.        the completeness of your lab report.



iLAB STEPS

STEP 1: Create a New Multifile Project

Create a new multifile project, and create a class to model complex-number, mathematical
operations using overloaded operators and add main() test functions to test the operations.

1.        Create a class for complex numbers that will provide the means to store both the real and
the imaginary values of a complex number.

2.        Design and add overloaded operators to perform correct and complex mathematical
operations on objects of the complex-number class.

STEP 2: Create and Add the Overloaded Operators

1.         Overload the addition operator (+) to perform complex mathmatical addition on two
objects of the complex-number class.

2.         Overload the subtraction operator (-) to perform complex mathmatical subtraction on two
objects of the complex-number class.

3.        Overload the multiplication operator (*) to perform complex mathmatical multiplication on
two objects of the complex-number class.
4.        Overload the division operator (/) to perform complex mathmatical division on two objects
of the complex-number class.

5.       Overload the assignment operator (=) to assign all the data values of an object in the
complex-number class to another object in the complex-number class.

STEP 3: Test the Overloaded Operators

Create at least three objects of the complex-number class in function main() and use them to
perform the following operation tests.

1.        Demonstrate the correct operation of the complex addition overloaded operator.

2.        Demonstrate the correct operation of the complex subtraction overloaded operator.

3.        Demonstrate the correct operation of the complex division overloaded operator.

4.        Demonstrate the correct operation of the complex multiplication overloaded operator.


CLICK HERE TO GET THE SOLUTION !!!!!!

Weitere ähnliche Inhalte

Kürzlich hochgeladen

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Empfohlen

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Empfohlen (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Comp 220 ilab 6 of 7

  • 1. HELPIDO.COM CLICK HERE TO GET THE SOLUTION !!!!!! COMP/220 iLab 6 of 7 - C++ Course iLab 6 of 7: Overloaded Operators iLAB OVERVIEW Scenario and Summary This lab is to introduce students to the concept of operator overloading as member functions of a class. This will be done in the context of creating a class that will perform four basic mathematical operations on complex numbers. The C++ compiler has defined operators for all the arithmetic and assignment operations for its native data types, such as integer, float, double, and so forth. However, for user-defined data types, such as classes and structures, these operations are undefined. C++ allows the programmer to create new definitions for these operators so that they can operate specifically on these user-defined data types. Which set of operators is actually called and implemented is decided during the compilation, and it is based on the data types of the operands involved in the operation. The ability to define a new set of data-type, dependent operations on existing operators, or functions, is called operator overloading. Deliverables 1. Submit a single Notepad file containing the source code for all files of the lab to the Week 5 Dropbox. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, YourLastName_Lab5.txt. Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes. 2. Submit a lab report (a Word document) containing the following information to the Week 6 Dropbox. o Include your name and the lab or lab exercise number. o Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
  • 2. o Test Plan: Include a brief description of the method you used to confirm that your program worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and actual results. o Summary and Conclusions: Write a statement summarizing your predicted and actual output, and identify and explain any differences. For conclusions, write at least one nontrivial paragraph that explains, in detail, either a significant problem you had and how you solved it or, if you had no significant problems, something you learned by doing the exercise. o A UML diagram: This should show all the classes, class members, access specifiers, data types, and function arguments, along with any and all class-to-class relationships. o Answers to Lab Questions: Include the answers to any and all lab questions asked in the lab steps. Each lab exercise should have a separate section in the lab-report document. Your lab grade is based upon 1. the formatting of your source code; 2. the use of meaningful identifiers; 3. the extent of internal documentation; 4. the degree to which an exercises’ specifications are met; and 5. the completeness of your lab report. iLAB STEPS STEP 1: Create a New Multifile Project Create a new multifile project, and create a class to model complex-number, mathematical operations using overloaded operators and add main() test functions to test the operations. 1. Create a class for complex numbers that will provide the means to store both the real and the imaginary values of a complex number. 2. Design and add overloaded operators to perform correct and complex mathematical operations on objects of the complex-number class. STEP 2: Create and Add the Overloaded Operators 1. Overload the addition operator (+) to perform complex mathmatical addition on two objects of the complex-number class. 2. Overload the subtraction operator (-) to perform complex mathmatical subtraction on two objects of the complex-number class. 3. Overload the multiplication operator (*) to perform complex mathmatical multiplication on two objects of the complex-number class.
  • 3. 4. Overload the division operator (/) to perform complex mathmatical division on two objects of the complex-number class. 5. Overload the assignment operator (=) to assign all the data values of an object in the complex-number class to another object in the complex-number class. STEP 3: Test the Overloaded Operators Create at least three objects of the complex-number class in function main() and use them to perform the following operation tests. 1. Demonstrate the correct operation of the complex addition overloaded operator. 2. Demonstrate the correct operation of the complex subtraction overloaded operator. 3. Demonstrate the correct operation of the complex division overloaded operator. 4. Demonstrate the correct operation of the complex multiplication overloaded operator. CLICK HERE TO GET THE SOLUTION !!!!!!