more help please

S

squeek

what i need help with determining functions how to word them and
variables to consider


A resistor is a circuit device designed to have a specific resistance
value between its ends. Resistance values are expressed in ohms or
kilo-ohms. Resistors are frequently marked with colored bands that
encode their resistance values. The first two bands from the left are
digits, and the third is a power-of-ten multiplier.

The table below shows the meanings of each band color. For example, if
the first band is green, the second is black, and the third is orange,
the resistor has a value of 50 x 103 ohms or 50 kilo-ohms. The
information in the table can be stored in a C++ program as a constant
array of strings.

const string COLOR_CODES[] = {"black, "brown", "red", "orange",
"yellow",
"green", "blue", "violet", "gray",
"white"};

Notice that "red" is COLOR_CODES[2] and has a digit value of 2 and a
multiplier value of 102. In general, COLOR_CODES[n] has digit value n
and multiplier value 10n.

Write a program that prompts the user for colors of Band 1, Band 2 and
Band 3, and then displays the resistance in ohms. Include a helper
function search(...) that takes three parameters - the list of color
codes, the size of the list and the key color to search for, and
returns the subscript of the list element that matches the key or
returns -1 if the key is not in the list. This index can then be used
to compute the resistance magnitude
black 0 100
brown 1 101
red 2 102
orange 3 103
yellow 4 104
green 5 105
blue 6 106
violet 7 107
gray 8 108
white 9 109

and i also got a scream shot to see final product but i didn't want to
waste download time with posting it whatever help i can get it would be
appreciated
thanks in advance
(e-mail address removed)
 
O

osmium

squeek said:
what i need help with determining functions how to word them and
variables to consider


A resistor is a circuit device designed to have a specific resistance
value between its ends. Resistance values are expressed in ohms or
kilo-ohms. Resistors are frequently marked with colored bands that
encode their resistance values. The first two bands from the left are
digits, and the third is a power-of-ten multiplier.

The table below shows the meanings of each band color. For example, if
the first band is green, the second is black, and the third is orange,
the resistor has a value of 50 x 103 ohms or 50 kilo-ohms.

50*103 = 5150 , NOT 50,000
The
information in the table can be stored in a C++ program as a constant
array of strings.

const string COLOR_CODES[] = {"black, "brown", "red", "orange",
"yellow",
"green", "blue", "violet", "gray",
"white"};

Notice that "red" is COLOR_CODES[2] and has a digit value of 2 and a
multiplier value of 102. In general, COLOR_CODES[n] has digit value n
and multiplier value 10n.

Those are not the rules. Could be a typing error but it looks more deeply
embedded than that. The above should read

Notice that "red" is COLOR_CODES[2] and has a digit value of 2 and a
multiplier value of [10^2]. In general, COLOR_CODES[n] has digit value n
and multiplier value [10^n]. Assuming the picture is correct, there is no
way you can reproduce those results with the rules you posted.

Write a program that prompts the user for colors of Band 1, Band 2 and
Band 3, and then displays the resistance in ohms. Include a helper
function search(...) that takes three parameters - the list of color
codes, the size of the list and the key color to search for, and
returns the subscript of the list element that matches the key or
returns -1 if the key is not in the list. This index can then be used
to compute the resistance magnitude
black 0 100
brown 1 101
red 2 102
orange 3 103
yellow 4 104
green 5 105
blue 6 106
violet 7 107
gray 8 108
white 9 109

and i also got a scream shot to see final product but i didn't want to
waste download time with posting it whatever help i can get it would be
appreciated

You don't have any choice with regard to a function names, or parameters or
anything else. Your instructor has decided he should do this for you. I
think he probably wants something like this:

int search(string* codes, int n_codes, string target_color)

Not a function name that I would choose. I would have called it something
like color_value(). But hey, he's the guy with the grade book.
 
D

Daniel T.

"squeek said:
what i need help with determining functions how to word them and
variables to consider


A resistor is a circuit device designed to have a specific resistance
value between its ends. Resistance values are expressed in ohms or
kilo-ohms. Resistors are frequently marked with colored bands that
encode their resistance values. The first two bands from the left are
digits, and the third is a power-of-ten multiplier.

The table below shows the meanings of each band color. For example, if
the first band is green, the second is black, and the third is orange,
the resistor has a value of 50 x 103 ohms or 50 kilo-ohms. The
information in the table can be stored in a C++ program as a constant
array of strings.

const string COLOR_CODES[] = {"black, "brown", "red", "orange",
"yellow",
"green", "blue", "violet", "gray",
"white"};

Notice that "red" is COLOR_CODES[2] and has a digit value of 2 and a
multiplier value of 102. In general, COLOR_CODES[n] has digit value n
and multiplier value 10n.

Write a program that prompts the user for colors of Band 1, Band 2 and
Band 3, and then displays the resistance in ohms. Include a helper
function search(...) that takes three parameters - the list of color
codes, the size of the list and the key color to search for, and
returns the subscript of the list element that matches the key or
returns -1 if the key is not in the list. This index can then be used
to compute the resistance magnitude
black 0 100
brown 1 101
red 2 102
orange 3 103
yellow 4 104
green 5 105
blue 6 106
violet 7 107
gray 8 108
white 9 109

and i also got a scream shot to see final product but i didn't want to
waste download time with posting it whatever help i can get it would be
appreciated
thanks in advance
(e-mail address removed)

#include <iostream>
#include <string>

using namespace std;

int search( const string* array, unsigned size, string target ) {
// add your code here
}

int main() {
const string first_try[1] = {"black"};
int result = search( first_try, 1, "foo" );
assert( result == -1 );
cout << "Working!\n";
}

Paste the above into your cpp file. Add code at the place where it says
"add your code here" until you can get "Working!" to print out when you
run it. Then show us what you did and we'll help you through the next
step.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Help please 8
Please Help? 0
Please help 2
Turtle program error. Please help! 1
Code help please 4
Need help again please 19
Help with my navigation, please 0
I dont get this. Please help me!! 2

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top