-45%
Placeholder

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

$149.99$275.00

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 7 Lab Polymorphism

This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in.

Description

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 7 Lab Polymorphism

This lab introduces students to the concepts of polymorphism, early binding, late binding, abstract classes, and virtual class functions. This will be done in the context of performing calculations on basic geometrical shapes. Polymorphism is a very powerful extension of inheritance, and by using pointers to the base class, it allows access to derived class objects and their functions based on the context that they are called in.

The lab will require the creation of a base geometric class, called Shape, and two sub classes, Circle and Rectangle, that are derived public from the class Shape. From there, objects of both the Circle and the Rectangle classes will be created, as will an array of pointers to the base class Shape. By using the instantiated objects and the object pointers, both static and dynamic binding will be demonstrated.

Deliverables

  1. Submit a single NotePad file containing the source code for all the lab files to the Week 7 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 7 Dropbox.
    • Include your name and the lab or lab exercise number.
    • Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
    • 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.
    • 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.
    • A UML Diagram: This should show all the classes, class members, access specifiers, data types, and function arguments, along with all of the class-to-class relationships.
    • Answers to Lab Questions: Include the answers to all the lab questions that are 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 the 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 with three classes: the base class Shape, the class Circle (derived public from Shape), and the class Rectangle (derived public from Shape). The classes will have the following requirements.

  1. The class Shape should be an abstract class with the following pure virtual functions.
    • area()
    • perimeter()
  2. The class Circle should be derived public from the class Shape and override both the area() and the perimeter() functions.
    • The perimeter() function should correctly calculate the circumference of a circle, given a radius.
    • The area() function should correctly calculate the area of a circle, given a radius
    • Include all the necessary accessor and mutator functions to accomplish the requirements of the class.
  3. The class Rectangle should be derived public from the class Shape and override both the area() and the perimeter() functions.
    • The perimeter() function should correctly calculate the circumference of a rectangle, given its dimensions.
    • The area() function should correctly calculate the area of a rectangle, given its dimensions.
    • Include all the necessary accessor and mutator functions to accomplish the requirements of the class.

STEP 2: Create the Test Function
Instantiate at least one object of each of the Circle and the Rectangle classes. Provide appropriate constructors for both that will accept the necessary initialization arguments to provide the information required for all the class member functions. Exercise and test each member function of both classes for correct calculations and output.

STEP 3: Add a Base Class Pointer Array and an Additional Function
Add to the test function a base class array of pointers of the same dimension as the total number of Circle and Rectangle objects that were created in the previous step. Use this pointer array to access the Circle and the Rectangle objects to call a new, nonclass member function that will display all the information about each object.

  1. Circle objects should display radius, circumference, and area.
  2. Rectangle objects should display dimensions, perimeter. and area.

The information-display function should accept as its calling parameter a pointer of the class Shape.

Run the test function to demonstrate static (early) binding using the derived class objects calling their member functions, and run the test function to demonstrate dynamic (late) binding using the assigned Shape class pointers to call the nonclass, member-display-information function.

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 6 Lab Overloaded Operators

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.
    • Include your name and the lab or lab exercise number.
    • Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
    • 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.
    • 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.
    • 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.
    • 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.

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 5 Lab Pointers and Pointer Operations

This lab will explore the use of pointers in several ways. Pointers will be used to dynamically allocate memory for new class objects on demand from the user, and they will be used to access class-member functions. Pointer arithmetic will be used to access and sort class objects according to criteria explained in the lab.

Pointers are, essentially, address variables, or variables that hold as their value the address of other variables. In terms of memory management, they are very powerful devices, and they more closely and efficiently use the actual internal hardware registers of the microprocessor that the program operates on.

Pointers also have the requirement that the pointer type must be of the same data type as the variable, or the data that it points to or holds the address of. The power of pointers also hints at the potential complexity of their use, which is why this lab is focused almost entirely on several different aspects and uses of pointers. The lab also introduces pointer arrays and pointers to pointers.

The Resistor class created in the Week 2 lab will be used as the class that the pointer operations will be used upon. The lab also requires the use of accessor functions and static data members, which may need to be added to the Resistor class definition and implementation.

Deliverables

  1. Submit a single Notepad file containing the source code for all the files of the lab to the Dropbox for Week 5. 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 Dropbox for Week 5.
    • Include your name and the lab or lab-exercise number.
    • Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
    • 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.
    • 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.
    • A UML diagram: This should show all classes, class members, access specifiers, data types, and function arguments, along with any and all class-to-class relationships.
    • Answers to Lab Questions: Answer any and all lab questions included in the lab steps.

Each lab exercise should have a separate section in the lab-report document.
Your lab grade will be 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 Multifile Project

Create a new multifile project using the Resistor class developed in Week 1, and include a new main() test function.

STEP 2: Modify the Resistor-Class Definition

  1. Add a static data member of the class Resistor to keep track of the number of Resistor objects that are dynamically created. This will also be used to limit the number of objects that are dynamically created to the maximum array size of the pointer array in the test function main().
  2. In the Resistor constructor, use a random-number generator to randomly assign a nominal resistance value to the object between 1,000 and 10,000 ohms. The resistance values are not required to be standard resistance values.

STEP 3: Create the Test Function Main() and the Support Function

  1. Create an array of pointers of type Resistor.
  2. Use elements of the pointer array to allow the user to dynamically allocate memory and to instantiate objects of the Resistor class.
  3. Use the indirect member-selection operator (pointer) in the test routine to access function members of the Resistor class.
  4. Write a new, nonclass function called in function main() to sort the pointers to the Resistor objects in order from lowest nominal resistance value to highest, passing a pointer to the Resistor-object pointer as the only passed data argument.
  5. Display the sorted Resistor objects according to the nominal resistance value, from lowest to highest.
  6. Within the sorting function, use pointer arithmetic to access the individual Resistor objects.
  7. Function main() should also ensure that there are no memory leaks when the program ends.

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 4 Lab Composition

This lab requires you to use C++ class composition to implement a single pole-filter design program. The program will allow the user to specify resistor and capacitor values and filter type. Once all the user parameters are specified, the program will return the cutoff frequency values for the filter.

Composition may be thought of as a has-a relationship for objects, as compared to inheritance, which may be described as an is-a relationship for objects.

You are required to use two component classes: one for a resistor object and one for a capacitor object. You are then to define and implement a filter class that will contain one object of each the resistor and the capacitor classes in order to create the filter and its characteristics.

The Resistor class created in the Week 2 iLab may be used both as the class definition for the resistor object and as a template or a guide for the capacitor-class definition.

The lab also requires you to implement your program in a multiple-file project and create both cpp and h files for each class defined. In addition, the program will have the capacity to save all filter parameters to a text file and read previously designed filter parameters from a text file.

Deliverables

  1. Submit a single .zip file containing the source code for all the files of the lab to the Dropbox for Week 4. 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_FirstName_Lab4.zip.
    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 Dropbox for Week 4.
      • Include your name and the lab or lab-exercise number.
      • Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
      • 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.
      • 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.
      • A UML diagram:

    This should show all classes, class members, access specifiers, data types, and function arguments, along with the composition relationship of the classes.

      • Answers to Lab Questions:

    The answers to any and all lab questions are included in the lab steps.

Each lab exercise should have a separate section in the lab-report document.
Your lab grade will be 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 Multifile Project for the Composition Lab

  1. Add three classes to the project: a Filter class, a Capacitor class, and a Resistor class.
  2. You may use the Resistor class files from the Week 2 lab for this lab.
  3. The Capacitor class should be modeled after the Resistor class for class members and operation.

STEP 2: Filter-Class Definition
The Filter class should have, at a minimum, the following capabilities.

  1. a resistor-object data member
  2. a capacitor-object data member
  3. a cutoff frequency (in Hertz) of the RC filter
  4. maximum and minimum cutoff frequencies, based on the maximum and minimum in-tolerance values of the capacitor and the resistor object
  5. a filter type, either low pass or high pass
  6. allow the user to enter new values for the filter, including
    6.1. resistor tolerance and nominal resistance;
    6.2. capacitor tolerance and nominal capacitance; and
    6.3. filter type
  7. provides the ability to write all capacitor, resistor, and filter data members to a formatted text file and allows the user to name the file
  8. provides the ability to read all capacitor, resistor, and filter data members from a formatted text file and allows the user to enter the file name and correctly handles a file-not-found error

STEP 3: Test-Program Operation

  1. All data-input and data-display operations (cin and cout) should be done in the function main() test program.
  2. The test program should instantiate at least one object of the class Filter.
    • The user should enter values for all the data members of the Filter, Resistor, and Capacitor classes.
    • The Filter class should then calculate and display the correct maximum and minimum cutoff frequencies.
  3. The test program should then display all Filter, Resistor, and Capacitor data members.

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 3 Lab Inheritance

This lab introduces you to writing a C++ program to implement the concept of class inheritance using different types of bank accounts as a model. In this lab, you will create a base class, called CBankAccount, and two additional classes (each derived from CBankAccount), called CSavingsAccount and CCheckingAccount. You will then test the operations of each class in function main() to simulate the transactions of both a checking account and a savings account.

Deliverables

  1. Submit a single Notepad file containing the source code for all the files of the lab to the Dropbox for Week 3. 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_Lab3.txt.
    Each program should include a comment section that includes (minimally) 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 Dropbox for Week 3.
    • Include your name and the lab or lab-exercise number.
    • Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
    • 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.
    • Summary and Conclusions: Include a summary of what the lab demonstrated and any conclusions drawn from the testing of the lab program.
    • Provide a UML diagram showing the base and the derived class relationships, access specifiers, data types, and function arguments.
    • Answers to Lab Questions: Answer any and all of the lab questions included in the lab steps.

Summary: Write a statement summarizing your predicted and actual output. Identify and explain any differences.

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.

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 the Multifile Project and the Main (Base) Class
Create a new project that consists of the base class BankAccount.
The BankAccount class should contain, at minimum, the following members.

  1. It should contain data members to store a bank customer’s balance and account number. These should be of different and appropriate data types.
  2. It should have function members that do the following:
    • set the account number;
    • return the account number;
    • return the account balance;
    • deposit money into the account; and
    • withdraw money from the account.

STEP 2: Create the CheckingAccount Class Derived From the BankAccount Class
The class CheckingAccount should contain, at a minimum, the following members.

  1. It should contain a data member to keep track of the number of withdrawal transactions made on the account. Whenever a withdrawal is made, this number should be incremented.
  2. Override the base class, withdraw-money function, and add the capability to deduct transaction fees from an account using the following guidelines.
    • The checking account is allowed three free transactions. For each successful withdrawal transaction past the three free transactions, there will be a service fee of 50 cents per transaction. The service fee should be deducted from the account balance at the time the transaction is made.
    • If there are insufficient funds in the account balance to cover the withdrawal plus the service fee, the withdrawal should be denied.
    • The function should return a value to indicate whether the transaction succeeded or failed. Transaction fees should be deducted only from successful transactions, but the transaction count should be incremented in either case.

STEP 3: Create the SavingsingAccount Class Derived From the BankAccount Class
The class CheckingAccount should contain, at a minimum, the following members.

  1. It should contain a data member to hold the daily interest rate. The daily interest rate can be calculated from a yearly interest rate by dividing the annual rate by 365.
  2. It should contain a data member to keep track of the number of days since the last transaction or balance inquiry. This should be updated using a random-number generator (reference Lab 1) that will return a value representing the number of days between 0 and 7, inclusive. We will assume that this bank is open every day of the year.
  3. It should contain a data member to hold the interest earned since the last transaction or balance inquiry.
  4. It should contain a function member to set the annual interest rate.
  5. Utilize the base-class functions for both withdrawal and deposit operations for the savings account.
  6. Override the base-class-balance inquiry function to add calculating and adding interest to the account based on the daily interest rate, the current balance of the account, and the number of days since the last balance inquiry. This should be called only when a balance inquiry is made, not when a deposit or withdrawal transaction or an account number inquiry is made.
  7. If there are insufficient funds in the account balance to cover a withdrawal, the withdrawal should be denied. The number of days since the last transaction or balance inquiry and the interest calculations should still be made.
  8. A value should be returned to indicate whether a withdrawal transaction succeeded or failed.
  9. It should contain a function member to return the interest earned since the last transaction or balance inquiry.
  10. It should contain a function member to return the number of days since the last transaction or balance inquiry.

STEP 4: Test Program Operation

  1. All data-input and data-display operations (cin and cout) should be done in the function main() test program.
  2. The test program should create one checking account and one savings account with initial balances of $100 each using the functions defined in the class definitions. The test program should also assign a unique, five-digit account number to each account and assign an annual interest rate of 3% for the savings account.
  3. The test program should then display a menu that allows the user to select which option is to be performed on which account, including the following.
  4. Make a deposit and specify the amount to a selected or an entered account.
  5. Make a withdrawal and specify the amount to a selected or an entered account.
  6. Return the balance of a selected or an entered account.
    • For deposit transactions, withdrawal transactions, and balance inquiries, the updated balance and any fees charged or interest earned should also be displayed.
    • For the savings account, the number of days since last transaction should be displayed.
  7. Exit the program.
  8. Each account operation should display the account number and the account type.

Lab Questions
Please answer all the lab questions in the text file that is to be turned into the Dropbox. You are not required to copy the question text into your document, but all answers should be listed with the question number they answer.

  1. Were any base-class functions called or overloaded in either of the derived classes? If so, list which class and which function, and explain why they were either called or overloaded.
  2. Were any derived-class functions not explicitly called by the test program? If so, list which class and function, and explain why this was done.
  3. Which access attribute was used for each of the classes derived from the base class? Why was this access attribute chosen?

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 2 Lab Classes Objects and Encapsulation

This lab requires you to create a multifile C++ project in order to design and implement an object-oriented program using a class to model the characteristics and function of a resistor.

Deliverables
Submit a single Notepad file containing the source code for Exercise 1 to the Dropbox for Week 2. 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; see the following example: YourLastName_Lab1.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.
Submit a lab report (a Word document) containing the following information to the Dropbox for Week 2.
Include your name and the exercise number.

iLAB STEPS
STEP 1: Create a Multifile Project
Objective: Create a C++ console application that will model the characteristics of a resistor.

  1. Create a multifile project. Create and add to the project an h file containing the resistor-class definition.
  2. Create and add to the project a cpp file containing the implementation of the class-member functions.
  3. Create and add to the project a ccp file containing the main() function, which will instantiate a resistor object and test its member functions.

STEP 2: Required Class Members
The resistor class will, at minimum, have members that do the following.

  1. store the nominal resistance value of a resistor
  2. store the tolerance of a resistor
  3. initialize any and all nominal-resistance values to correct, EIA, nonzero values that are greater than 0 and less than 1,000,000 ohms
  4. initialize any and all resistance-tolerance values to correct, E12, E24, E48, or E96 resistance-tolerance values
  5. allow the nominal-resistance and tolerance values of a resistor object to be changed by the user
  6. All member functions should have a test message stating the name of the function. All the test messages should be displayed or not displayed, depending on the value of a Boolean variable declared in main().
    • If the Boolean value = true, display the message.
    • If the Boolean value = false, do not display the message.

STEP 3: Program Operations

  1. Function main() should instatiate two objects of class resistor.
  2. Function main() should display the current values of all resistor objects.
    Function main() should also calculate and display the minimum and maximum in-tolerance resistance values of each resistor object from the resistor data members.
  3. Function main() should allow the user to change the values of the nominal resistance and the resistor tolerance of both resistor objects, and it should also correctly handle out of numeric-range input. Main() is also responsible for making sure that the user can successfully enter only correct, EIA resistance and tolerance values.
    The user should be given the following data-entry choices:
    accept current EIA values for resistance and tolerance;
  4. The function main() should display the new, modified values of the resistor object, including the new min and max in-tolerance resistance values.
  5. The function main() should be executed twice: once with the test messages displayed and once without.

STEP 4: Lab Questions
You are not required to copy the question text into your document, but all answers should be listed with the question number they answer.

  1. List the complete reference-source information for where you found the EIA standard resistor value and tolerance information.
  2. How was this reference discovered and where?
  3. The constructor requires the initialization values for the nominal resistance and the tolerance when an object is instantiated to be a correct E-series resistance and tolerance combination. Describe how this was accomplished in your program design and implementation.
  4. In the lab, you were required to provide mutator functions to change the nominal-resistance and tolerance values of a resistor object.
    Describe how this was accomplished so that the user could not enter an invalid nominal-resistance and E-series tolerance combination.
  5. Describe how this process was different and/or similar to how you implemented this validation in the class constructor.

COMP 220 COMP220 COMP/220 ENTIRE COURSE HELP – SOUTHERN ALBERTA INSTITUTE OF TECHNOLOGY (SAIT)

COMP 220 Week 1 Lab Two-Dimensional Arrays

This lab requires you to design and implement a C++ program to simulate a game of Blackjack between two to four players. Your program must incorporate a two-dimensional array to represent the suit and the value of each card dealt to a player, keep track of which cards have been dealt to which player, and use a random-number generator to pick each card to be dealt to a player.

Deliverables

  1. Submit a single Notepad file containing the source code for Lab 1 to the Dropbox for Week 1. 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,
    Y ourLastName_Lab1.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 Dropbox for Week 1.
    • Include your name and the exercise number.
    • Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output.
    • 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.
    • Summary and Conclusions: Write a statement summarizing your predicted and actual output, and identify and explain any differences. For your 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.
    • Answers to Lab Questions: Answer any and all of the lab questions included in the lab steps.

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

iLAB STEPS
STEP 1: Starting Visual Studio
Create a new Visual Studio empty project, and add one C++ source code file.

STEP 2: Coding
Enter the following source, which will set up the 2D array and the recommended variable declarations. It is up to the student to design and implement the remainder of the program code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Programmer: (put your name here)
// Course: COMP220
// Assignment: Two-Dimensional Arrays
// Description: The program will use a 2D array and a random-number
// generation to play Blackjack and keep track of a playing-card deck.
// Input: User data entry and a playing-card deck represented as a two- // dimensional array
// Output: A screen display showing the current card hands of each player
// and the dealer, their score, win and lose status, and a final representation // of the card deck after the game is over
#include<iostream>
#include<iomanip>
#include<windows.h>
using namespace std; void main (void)
{
bool bPlayerDraw[5]; //Boolean to determine if player holds (F)
//or draws card (T)
char cPlay = 'N'; //Character variable for play game input
char cCardDeck[4][13]; //Character array representing the card deck
int iCard;
//0 = 2 card
//1 = 3 card
//2 = 4 card
//3 = 5 card
//4 = 6 card
//5 = 7 card
//6 = 8 card
//7 = 9 card
//8 = 10 card
//9 = jack card //10 = queen card //11 = king card //12 = ace card
int iNumberOfDraws = 0; //Number of rounds of card draws int iSuit; //Suit array index
//0 = diamonds //1 = hearts //2 = clubs
//3 = spades
// ASCII character display reference for display card suit symbols //3 = heart symbol
//4 = diamond symbol
//5 = club symbol
//6 = spade symbol
int iNumberOfPlayers = 0;//Number of players in current game
int iPlayerCount[5]; //Integer array to holder each player's count
//iPlayer[0] is always the dealer
int iHighestCount = 0; //Highest count for a single game
int k, m; //integer loop counters srand(GetTickCount()); //Seed the random-number generator
//Main game loop //Enter your code here...

A sample output of the program is below:
Welcome to Honest Sam’s Blackjack Table Glad to have you back!
Enter the number of players in the game.
There must be at least one player but no more than four.
Number of players: 3
[table]
, Card 1 , Card 2 , Card 3 , Total , Stats
Dealer , J♦ , 10♦ , 9♣ , 29 , Lose
Player 1, K♣ , 2♠ , 5♥ , 17 , Lose
Player 2 , J♣ , Q♥ , 10♥ , 30 , Lose
Player 3 , 3♦ , 8♣ , K♦ , 21 , Win!

[/table]

STEP 3: Program Specifications

  1. There is always a dealer in the game. The dealer draws 3 cards.
  2. There must be at least one other player (you) and up to a maximum of four other players (all played by you).
    • Each player will draw 3 cards.
    • All the cards for each player, including the first card dealt, are displayed, along with the suit symbol: spades ♠, clubs ♣, hearts ♥, or diamonds ♦.
  3. Each game will start with a new, 52-card deck, which is modeled on a real deck of cards.
  4. The card deck has 52 cards with no jokers.
  5. The card deck is represented by a two-dimensional array of data-type character, where the first dimension represents the suit and the second dimension represents the card in the suit, such as the following.
    char CardDeck[4][13];
  6. At the start of each game, each element of the two-dimensional array is initialized to a value of ” “, or the “space” character.
  7. The deck has four suits, represented by the following dimension indices.
    • 0 = diamonds
    • 1 = hearts
    • 2 = clubs
    • 3 = spades
  8. Each suit has 13 cards: 2, 3, 4, 5, 6, 7, 8, 9 ,10, jack, queen, king, and ace.
  9. Each card in a suit is represented by the following dimension indices.
    • 0 = the 2 card
    • 1 = the 3 card
    • 2 = the 4 card
    • 3 = the 5 card
    • 4 = the 6 card
    • 5 = the 7 card
    • 6 = the 8 card
    • 7 = the 9 card
    • 8 = the 10 card
    • 9 = the jack
    • 10 = the queen
    • 11 = the king
    • 12 = the ace
  10. All the number cards are worth their face value (i.e., a 3 of diamonds is worth 3).
  11. All face cards are worth 10.
  12. An ace is worth either 1 or 11. Your final-score calculation must be able to handle this correctly for both the dealer and each player.
  13. A random-number generator must be used to select the suit and the card in the suit.
    Once a card and suit are selected, the program should check if the value of that array element is a “space.”

    • If the array element = “space,” set the element equal to an integer, identifying the dealer or the player.
      • 0 = dealer
      • 1 = player 1
      • 2 = player 2
      • 3 = player 3
      • 4 = player 4
    • If the array element ! = “space,” then the random-number and card- checking process should repeat until a “card” or an array element is selected that is = “space.”
  14. Once a card is drawn during a game, it cannot be drawn again.
  15. If the user inputs to play the game, the next decision should be 1, 2, 3, or 4 players.
  16. The game ends when each player has 3 cards.
  17. The display should show each player’s (and the dealer’s) hand and update the display after each round of card draws.
  18. At the end of a game, the an updated balance.