473,804 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.ed u

Apr 4 '06 #1
3 2821
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************ *********@i39g2 000cwa.googlegr oups.com>,
"squeek" <ac*****@siue.e du> 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.ed u


#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
17806
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. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
4
6177
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 values from a html form that consists of about 10 checkbox and a textbox where user have to key in a value to perform a search. From python tutors, I learned that I have to use the following method:
21
3925
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 table1"; var obj=new ActiveXObject("ADODB.Recordset");
0
3042
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! Follow the simple directions and watch the money come in!! It's easy. It's legal. And, your investment is only $6.00 (Plus postage)!!!
26
4505
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 System.EnterpriseServices;
7
6249
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 about the error and where it originated in the code. Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters. Source Error:
15
2439
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 that are formatted for number and then half way down they are changed to text. OR the famous ok now everything in red is ---- and everything in blue is---------. WTF are these people thinking?
0
4615
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' Application. -------------------------------------------------------------------------------- No value given for one or more required parameters. Description: An unhandled exception occurred during the execution of the current web request. Please...
12
1733
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 set //fp is pre-defined for(;!fp.eof();) { string linestr;
6
1630
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 htmlform to catch the attribute 'action' wich contains the url where the post will occur and replace it with a safe url. Unfortunately, it doesn't works, does something has changed with framework 3.5 used by vs2008 ? From the trace I put inside I can...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9171
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5530
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.