Please help me with this question! It is due by midnight! I'm doing this in Visual Studio 2019. But any others are fine as long as it can compile.
I also wanted to see the results if it is compiled and QT comments as well. Please respond immediately!
Screenshot
--------------------------------------------------------
Program
main.cpp
#include <iostream>
#include<iomanip>
#include<vector>
#include<cstdlib>
#include "Resistance.h"
using namespace std;
int main()
{
//Create a vector for resistance
vector<Resistance> resistances;
//Tolerance vector
vector<double>tolerances;
//Add 2 tolerances randomly for check
for (int i = 0; i < 2; i++) {
double r = (double)rand() /
RAND_MAX;
tolerances.push_back(.05 + (fmod(r,
(20 - .05 + 1))));
}
//Create 2 resistances
Resistance r1(4.8,2,tolerances.at(0));
resistances.push_back(r1);
Resistance r2(6.2,5,tolerances.at(1));
resistances.push_back(r2);
//Display details
for (int i = 0; i < 2; i++) {
double resistance =
resistances.at(i).getactualResistance();
cout << fixed <<
setprecision(2) <<resistance <<"KOhm"<<
endl;
resistances.at(i).colorBand(resistance);
cout << endl;
}
}
Resistance.h
#pragma once
#include<cstdlib>
#include<iostream>
#include<string>
using namespace std;
//Craete a class Resistance
class Resistance {
//Attributes
private:
double nominalResistance;
int multiplier;
double tolerance;
//Member functions
public:
//constructor
Resistance(double, int, double);
//getters
double getNominalResistance()const;
double getTolerance()const;
double getactualResistance()const;
//color band description
void colorBand(double);
};
Resistance.cpp
#include "Resistance.h"
//Constructor implementation
Resistance::Resistance(double nominal, int mult, double tol){
nominalResistance = nominal;
multiplier = mult;
tolerance = tol;
}
//getters implementation
double Resistance::getNominalResistance()const {
return nominalResistance;
}
double Resistance::getTolerance()const {
return tolerance;
}
double Resistance::getactualResistance()const {
double toleranceVal = nominalResistance *
(double(tolerance) / 100);
double resistance1 = nominalResistance -
toleranceVal;
double resistance2 = nominalResistance +
toleranceVal;
double r = (double)rand() / RAND_MAX;
return resistance1 + (fmod(r, (resistance2 -
resistance1 + 1)));;
}
//color band description
void Resistance::colorBand(double actualResistance) {
int temp = actualResistance * 1000;
int firstBand = temp / 1000;
int secondBand = (temp / 100) % 10;
string colors[] = {
"Black","Brown","Red","Orange","Yellow","Green","Blue","Violet","Gray","White","Gold/Silver/None"
};
cout << "First Band:
"<<colors[firstBand]<< endl;
cout << "First Band: " <<
colors[secondBand] << endl;
cout << "Multiplier: " <<
colors[multiplier] << endl;
if (tolerance == 1) {
cout << "Tolerance: Brown"
<< endl;
}
else if (tolerance == 2) {
cout << "tolerance: red"
<< endl;
}
else if (tolerance == 0.5) {
cout << "First Band: Green"
<< endl;
}
else if(tolerance == .25) {
cout << "First Band: Blue"
<< endl;
}
else if (tolerance == .1) {
cout << "First Band: Violet"
<< endl;
}
else if (tolerance == .05) {
cout << "First Band: Gray"
<< endl;
}
else if (tolerance == 5) {
cout << "First Band: Gold"
<< endl;
}
else if (tolerance == 10) {
cout << "First Band: Silver"
<< endl;
}
else if (tolerance == 20) {
cout << "First Band: None"
<< endl;
}
else {
cout << "First Band:
black/Orange/Yellow/White" << endl;
}
}
--------------------------------
output
4.99KOhm
First Band: Yellow
First Band: White
Multiplier: Red
First Band: black/Orange/Yellow/White
6.97KOhm
First Band: Blue
First Band: White
Multiplier: Green
First Band: black/Orange/Yellow/White
-----------------------------------------------------
Note
Here i test only 2 values due to time limit,Please add more test values.
Please help me with this question! It is due by midnight! I'm doing this in Visual...
Please help. Part 3: Using the color coding for resistors, determine the resistance and the tolerance for the following 3 resistors: exornn Rbolor coding: brown, black, yellow, gold Rgcolor coding: red, violet, orange, gold Rocolor coding: orange, orange, orange, gold The chage nowng thonuh a sece is every themes Find out the outest throsgh the sistance is diven e well se the colot code fur esch of the resistors 4-Band-Code 2%, 5%, 10% 560k Ω 5% 1ST BAND | 2ND...
of 1 m of string: Class Section Length of the string H029 L-1552 gm M (g) kg/m A (cm) Prelab Section Class Name Turn in the prelab at the beginning of class to get credit. Identify your resistances according to the figure below Black Brown Red Fourth Band 2nd Digt No of Zes None 120% Silver 110% Gold 15% t2% Ist Digit- Tolerance Orange Yellow Rod X axis. Green Bloe Violet Gray Whise 9 oints) ar alculate 1. What is...
Figure 1(a) shows a combination of series and parallel circuit while Table 1 lists the colour code of 4-band resistor. The voltage source, vs is indicated in Figure 1(b). (a) Find the nominal value of resistor Rand the range of its actual resistance. (2 marks) (b) Using the nominal value of RL, compute the effective voltage across Rt. (6 marks) (c) Using the nominal value of Ru, calculate the average power dissipated in RL. (2 marks) 350 22 ş 150...
Notes for lab dc02-Resistors and the Color Code will skip are Part 2 e, g: Part 4; Exercises 2, 4,5,6 and 3. It is important to answer the exercises correctly in each labl you should include the appropriate prefix for the unit in the Numerical Value We will not be Volt using the Volt-Ohm meter (VOM) for this lab, so skip the parts that ask for VOM measurements. The parts we You do need to complete Exercises1 Note that in...
Pease answer questions 4 and 5! Thank you so much! 4. Connect the 2nd resistor in parallel with the 1st resistor and connect that combination to the battery. Measure the following: The current passing through the R1, I1 = ___0.0058____ A The current passing through the R2, I2 = ___0.0031____ A The current supplied by the battery, I = ___0.0092____ A Calculate I1 + I2 = ____________ A Is the following statement true? I = I1 +...
Need #8 attached a cleared picture of the graph Nomina Measured Part 1: Loop Method- Calculations Ri 13. 3. Determine the nominal resistance and tolerance of each resistor by reading its color code. They should have the following approximate resistances: (5 pts) R1-10 Ω R2-12Ω 3 R 22 R4 = 18 Ω R-22 Ω 4. Measure the resistance of each resistor using an ohm- meter. (5 pts) 5. Measure e of the two batteries using a voltmeter They should be...
Hello, Can you answer the following question using the charts and picture I've provided? Thank You so Much! Information Needed to Solve the Question (2) The two resistors, Ri and R2, shown at the top of Figure 3(a) will be used in Experımehl i. Using the colour code in Table 1, write the corresponding colour and the digit in the t below for each resistor. See the example in Figure 10. Record the values of Ri and R2 with their...
The following code must be written and run with no errors in java eclipse Description of the code to be written: A resistor is an electronic part colour-coded with three coloured bands to indicate its resistance value. This program returns the resistance of a Resistor object instantiated with three Strings, representing the three colour bands of a real resistor. Start by creating an abstract class 'AbstractResistor' that implements the Comparable interface. This class should have the following three private methods:...
Answer 4 & 5 please! thank you! R values = Resistor value, R1 = 990 Ohms Resistor value, R2 = 2050 Ohms 4. Connect the 2nd resistor in parallel with the 1st resistor and connect that combination to the battery. Measure the following: The current passing through the R1, I1 = ___0.0058____ A The current passing through the R2, I2 = ___0.0031____ A The current supplied by the battery, I = ___0.0092____ A Calculate I1 + I2 =...
15 Electrical Circuits rou have hund that greater ' esistance in a creur results is lower ement A ate resistaace to is a naisance. 1 currest, Teo nuch euerent could easily the circuits in your caleulatee Band one. 1T example in ohms (2) the resistor 4-band hat yields 2 significant figures of precision, is shown belew, seme resisters utt 5 bands for 3 sig figs Put the first two digits sogether and Indicabes Resistor Acouracw then muhiply by Band 3...