Discount Get COMP 220 ALL WEEKS Solution ONLY $92.95 $123.93
COMP 220 Week 1 - Blackjack Program C++ [$19.99]
COMP 220 Week 2 - Resistor Program C++ [$15.99]
COMP 220 Week 3 - Bank Account Program C++ [$19.99]
COMP 220 Week 4 - Filter Program C++ [$19.99]
COMP 220 Week 5 - Pointers and Pointer Operations C++ [$15.99]
COMP 220 Week 6 - Filter Program C++ [$15.99]
COMP 220 Week 7 - Polymorphism C++ [$15.99]
Get Selected Weeks Solution with ONLY NOT Add Selected Tutorials To Cart
COMP220 COMP 220 COMP/220 Week 4 - Lab 4 - iLab 4 - Filter Program C++
    COMP220 COMP 220 COMP/220 Week 4 - Lab 4 - iLab 4 - Filter Program C++

COMP220 COMP 220 COMP/220 Week 4 - Lab 4 - iLab 4 - Filter Program C++

$19.99

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.

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.
a. The user should enter values for all the data members of the Filter, Resistor, and Capacitor classes.
b. 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.

REQUIRED MAIN

You are required to use this int main()  DRIVER / TEST FILE.

#include "Capacitor.h"

#include <conio.h>

#include "Filter.h"

#include <iostream>

#include "Resistor.h"

#include <windows.h>

#include <iomanip>

using namespace std;

void clear_screen(void);

void main(void)

{

 // Local variable for text data entry

 char tempName[16];

 // Local variable for component value data entry

 double tempValue;

 cout << "Instantiate one object of class Filter" << endl << endl;

 cout << "Enter a name for the new filter object:  ";

 cin.getline(tempName,15,'\n');

 Filter filt1;

 // Display filter values

 cout << setiosflags(ios::fixed)

  << setiosflags(ios::right)

  << setiosflags(ios::showpoint)

  << setprecision(3);

 cout << endl << endl;

 cout << "Nominal Filter Frequency =   " << setw(10) << filt1.getFilter() << " Hertz" << endl;

 cout << "Minimum Filter Frequency =   " << setw(10) << filt1.getMaxFilter() << " Hertz" << endl;

 cout << "Maximum Filter Frequency =   " << setw(10) << filt1.getMinFilter() << " Hertz" << endl;

 cout << "Filter Bandwidth Frequency = " << setw(10) << filt1.getFilterTol() << " Hertz" << endl;

 // Display resistor values

 cout << setiosflags(ios::fixed)

   << setiosflags(ios::right)

   << setiosflags(ios::showpoint)

   << setprecision(3);

 cout << endl << endl;

 cout << "Nominal Resistance Value =   " << setw(10) << filt1.getResistance() << " ohms" << endl;

 cout << "Resistor Tolerance Value =   " << setw(10) << filt1.getResTolerance()*100 << " Percent" << endl;

 cout << "Maximum Resistance Value =   " << setw(10) << filt1.getMaxResistance() << " ohms" << endl;

 cout << "Minimum Resistance Value =   " << setw(10) << filt1.getMinResistance() << " ohms" << endl;

 cout << endl << endl;

 // Display capacitor values

 cout << setiosflags(ios::fixed)

   << setiosflags(ios::showpoint)

   << setiosflags(ios::left)

   << setprecision(3);

 cout << "Nominal Capacitance Value =  " << setw(10) << filt1.getCapacitance() *1000000<< " micro Farads" << endl;

 cout << "Capacitor Tolerance Value =  " << setw(10) << filt1.getCapTolerance()*100 << " Percent" << endl;

 cout << "Maximum Capacitance Value =  " << setw(10) << filt1.getMaxCapacitance() * 1000000 << " micro Farads" << endl;

 cout << "Minimum Capacitance Value =  " << setw(10) << filt1.getMinCapacitance() * 1000000<< " micro Farads" << endl;

 cout << endl << endl;

 //filt1.FilterSave();

 cout << "Enter new nominal resistance value for filter:  ";

 cin >> tempValue;

 filt1.setResistance(tempValue);

 cout << "Enter new resistance tolerance value for filter:  ";

 cin >> tempValue;

 filt1.setResTolerance(tempValue/100.0);

 cout << "Enter new nominal micro Farad capacitance value for filter:  ";

 cin >> tempValue;

 filt1.setCapacitance(tempValue/1000000.0);

 cout << "Enter new capacitance tolerance value for filter:  ";

 cin >> tempValue;

filt1.setCapTolerance(tempValue/100.0);   /// This line of code was fixed

 // Calculate filter values based on new resistance and capacitance values

 filt1.calculateFilter();

 // Display filter values

 cout << setiosflags(ios::fixed)

  << setiosflags(ios::right)

  << setiosflags(ios::showpoint)

  << setprecision(3);

 cout << endl << endl;

 cout << "Nominal Filter Frequency =   " << setw(10) << filt1.getFilter() << " Hertz" << endl;

 cout << "Minimum Filter Frequency =   " << setw(10) << filt1.getMaxFilter() << " Hertz" << endl;

 cout << "Maximum Filter Frequency =   " << setw(10) << filt1.getMinFilter() << " Hertz" << endl;

 cout << "Filter Bandwidth Frequency = " << setw(10) << filt1.getFilterTol() << " Hertz" << endl;

 // Display resistor values

 cout << setiosflags(ios::fixed)

   << resetiosflags(ios::left)

   << setiosflags(ios::right)

   << setiosflags(ios::showpoint)

   << setprecision(3);

 cout << endl << endl;

 cout << "Nominal Resistance Value =   " << setw(10) << filt1.getResistance() << " ohms" << endl;

 cout << "Resistor Tolerance Value =   " << setw(10) << filt1.getResTolerance()*100 << " Percent" << endl;

 cout << "Maximum Resistance Value =   " << setw(10) << filt1.getMaxResistance() << " ohms" << endl;

 cout << "Minimum Resistance Value =   " << setw(10) << filt1.getMinResistance() << " ohms" << endl;

 cout << endl << endl;

 cout << setiosflags(ios::fixed)

   << setiosflags(ios::showpoint)

   << setiosflags(ios::left)

   << setprecision(3);

 cout << "Nominal Capacitance Value =  " << setw(10) << filt1.getCapacitance() *1000000<< " micro Farads" << endl;

 cout << "Capacitor Tolerance Value =  " << setw(10) << filt1.getCapTolerance()*100 << " Percent" << endl;

 cout << "Maximum Capacitance Value =  " << setw(10) << filt1.getMaxCapacitance() * 1000000 << " micro Farads" << endl;

 cout << "Minimum Capacitance Value =  " << setw(10) << filt1.getMinCapacitance() * 1000000<< " micro Farads" << endl;

 cout << endl << endl;

 filt1.FilterRead();

 //filt1.calculateFilter();

 // Display filter values

 cout << setiosflags(ios::fixed)

  << setiosflags(ios::right)

  << setiosflags(ios::showpoint)

  << setprecision(3);

 cout << endl << endl;

 cout << "Nominal Filter Frequency =   " << setw(10) << filt1.getFilter() << " Hertz" << endl;

 cout << "Minimum Filter Frequency =   " << setw(10) << filt1.getMaxFilter() << " Hertz" << endl;

 cout << "Maximum Filter Frequency =   " << setw(10) << filt1.getMinFilter() << " Hertz" << endl;

 cout << "Filter Bandwidth Frequency = " << setw(10) << filt1.getFilterTol() << " Hertz" << endl;

 // Display resistor values

 cout << setiosflags(ios::fixed)

   << resetiosflags(ios::left)

   << setiosflags(ios::right)

   << setiosflags(ios::showpoint)

   << setprecision(3);

 cout << endl << endl;

 cout << "Nominal Resistance Value =   " << setw(10) << filt1.getResistance() << " ohms" << endl;

 cout << "Resistor Tolerance Value =   " << setw(10) << filt1.getResTolerance()*100 << " Percent" << endl;

 cout << "Maximum Resistance Value =   " << setw(10) << filt1.getMaxResistance() << " ohms" << endl;

 cout << "Minimum Resistance Value =   " << setw(10) << filt1.getMinResistance() << " ohms" << endl;

 cout << endl << endl;

 cout << setiosflags(ios::fixed)

   << setiosflags(ios::showpoint)

   << setiosflags(ios::left)

   << setprecision(3);

 cout << "Nominal Capacitance Value =  " << setw(10) << filt1.getCapacitance() *1000000<< " micro Farads" << endl;

 cout << "Capacitor Tolerance Value =  " << setw(10) << filt1.getCapTolerance()*100 << " Percent" << endl;

 cout << "Maximum Capacitance Value =  " << setw(10) << filt1.getMaxCapacitance() * 1000000 << " micro Farads" << endl;

 cout << "Minimum Capacitance Value =  " << setw(10) << filt1.getMinCapacitance() * 1000000<< " micro Farads" << endl;

 cout << endl << endl;

}

My tutorial contains Visual C++ 2010 Project.

If you have more questions, please contact me via email support@extutorials.com

I will help you any time

Thank you !

Attached Files

Move over [ preview ] file name to preview content in it!

  • COMP220 iLab4.zip [29.8KB]
    • COMP220 iLab4
      • Capacitor.cpp [0.9KB] [ preview ]
      • Capacitor.h [0.4KB] [ preview ]
      • COMP220 iLab4.vcxproj [4.2KB]
      • COMP220 iLab4.vcxproj.filters [1.5KB]
      • COMP220 iLab4.vcxproj.user [0.1KB]
      • data.txt [0.4KB] [ preview ]
      • Filter.cpp [1.2KB] [ preview ]
      • Filter.h [0.4KB] [ preview ]
      • Resistor.cpp [0.9KB] [ preview ]
      • Resistor.h [0.4KB] [ preview ]
      • TestMain.cpp [0.8KB] [ preview ]
    • COMP220 iLab4.sln [0.9KB]
    • COMP220 iLab4.suo [17.4KB]

Write a review

Your Name:


Your Review: Note: HTML is not translated!

Rating: Bad           Good

Enter the code in the box below:



PURCHASE SAVE
2 Tutorials 10%
3 Tutorials 13%
4 Tutorials 16%
5 Tutorials 19%
6 Tutorials 22%
7 Tutorials 25%
8 Tutorials 28%
9 Tutorials 31%
10 Tutorials 34%
add url more

9MZQASHWN73B