473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

more help please

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
ac*****@siue.edu

Apr 4 '06 #1
3 2792
squeek wrote:
what i need help with determining functions how to word them and
variables to consider


The FAQ covers this question:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.2
[5.2] How do I get other people to do my homework problem for me?

Always check the FAQ (and Google) before posting.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
Apr 4 '06 #2
"squeek" writes:
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.
Apr 4 '06 #3
In article <11*********************@i39g2000cwa.googlegroups. com>,
"squeek" <ac*****@siue.edu> wrote:
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
ac*****@siue.edu


#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.
--
Magic depends on tradition and belief. It does not welcome observation,
nor does it profit by experiment. On the other hand, science is based
on experience; it is open to correction by observation and experiment.
Apr 4 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
4
by: Shufen | last post by:
Hi, I'm a newbie that just started to learn python, html and etc. I have some questions to ask and hope that someone can help me on. I'm trying to code a python script (with HTML) to get...
21
by: Rabbit63 | last post by:
Hi: I want to show a set of records in the database table on the clicnt browser. I have two ways to do this (writen in JScript): 1.The first way is: <% var sql = "select firstname from...
0
by: power | last post by:
Suggestion: Read this entire message carefully!! (Print it out or download it) http://network4life.tripod.com/ (check this out) BE PREPARED TO GET EXCITED.... YOU WON'T BE DISAPPOINTED! ...
26
by: Lasse Edsvik | last post by:
Hello I'm trying to build a simple COM+ app in vs.net using C# and i cant register it in component manager..... what more is needed than this: using System; using...
7
by: mp | last post by:
No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
15
by: sparks | last post by:
We get more and more data done in excel and then they want it imported into access. The data is just stupid....values of 1 to 5 we get a lot of 0's ok that alright but 1-jan ? we get colums...
0
by: AxleWacl | last post by:
Hi, The below error is what I am receiving. The code im using is below the error, for the life of me, I can not see where any parameter is missing..... Server Error in '/FleetcubeNews'...
12
by: pedagani | last post by:
Dear comp.lang.c++, Could you make this snippet more efficient? As you see I have too many variables introduced in the code. //Read set of integers from a file on line by line basis in a STL...
6
by: WT | last post by:
Hello, Using url rewritting and ajax.net, I tried to circumvent some potential problems with postback url using a code from a sample given by Scott. The idea is to use a control Adapter on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.