473,382 Members | 1,377 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,382 software developers and data experts.

pico, nano, micro and Java

First off, this is for a school assignment... I know some people get
squeamish about this sort of post, but I'm kind of up a creek.

Basically, as part of a semester-long project, we need to add another bean
to a program we've been working on, and integrate it with the rest of the
program. That part's not the issue.

Part of the specification for the bean states tnat the user must be able to
select (and optionally enter) values ranging from 100 picofarads up to 1
microfarad. That's 1 * 10^-10 up to 1 * 10^-6, and everything in between.
Now... For ease of use purposes, the input is supposed to involve something
like a combobox or a spinner or a slider, or something like that, with
clearly delineated default values, which the user can then customise.

So, for testing purposes, I have a combobox containing the numbers 1 to 10,
and a second combobox that allows you to select your unit (pF, nF, uF).

So... In an attempt to get this post over with... Does Java include a
quick and easy way of taking an entry like "250 nF" and converting it to
2.5*10^-7 for calculation purposes? I was thinking of putting the whole
thing into a switch based on the contents of the units box (or possibly a
bunch of if statements), but then there's the problem of a certain amount of
variation in the multipliers used depending on the actual number entered.

Does any of this make sense?
Apr 14 '06 #1
2 9282
Paul in Toronto wrote:
First off, this is for a school assignment... I know some people get
squeamish about this sort of post, but I'm kind of up a creek.

Basically, as part of a semester-long project, we need to add another bean
to a program we've been working on, and integrate it with the rest of the
program. That part's not the issue.

Part of the specification for the bean states tnat the user must be able to
select (and optionally enter) values ranging from 100 picofarads up to 1
microfarad. That's 1 * 10^-10 up to 1 * 10^-6, and everything in between.
Now... For ease of use purposes, the input is supposed to involve something
like a combobox or a spinner or a slider, or something like that, with
clearly delineated default values, which the user can then customise.

So, for testing purposes, I have a combobox containing the numbers 1 to 10,
and a second combobox that allows you to select your unit (pF, nF, uF).

So... In an attempt to get this post over with... Does Java include a
quick and easy way of taking an entry like "250 nF" and converting it to
2.5*10^-7 for calculation purposes? I was thinking of putting the whole
thing into a switch based on the contents of the units box (or possibly a
bunch of if statements), but then there's the problem of a certain amount of
variation in the multipliers used depending on the actual number entered.

Does any of this make sense?

Think you want to look at the java.math.BigDecimal and
java.lang.Math.pow(double x, double p) classes. You need to check the
API for more info.

For pow(double x, double p) It returns the value of the first argument
raised to the power of the second argument.
--

Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________ ________________________

'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Apr 14 '06 #2
"Paul in Toronto" <sw********@hotmail.com> wrote in message
news:gy*******************@news20.bellglobal.com.. .

Part of the specification for the bean states tnat the user must be able
to select (and optionally enter) values ranging from 100 picofarads up to
1 microfarad. That's 1 * 10^-10 up to 1 * 10^-6, and everything in
between. Now... For ease of use purposes, the input is supposed to
involve something like a combobox or a spinner or a slider, or something
like that, with clearly delineated default values, which the user can then
customise.

So, for testing purposes, I have a combobox containing the numbers 1 to
10, and a second combobox that allows you to select your unit (pF, nF,
uF).

So... In an attempt to get this post over with... Does Java include a
quick and easy way of taking an entry like "250 nF" and converting it to
2.5*10^-7 for calculation purposes? I was thinking of putting the whole
thing into a switch based on the contents of the units box (or possibly a
bunch of if statements), but then there's the problem of a certain amount
of variation in the multipliers used depending on the actual number
entered.

Does any of this make sense?


Rather than 2 combo boxes, you should probably go with 1 combo box and 1
slider, or one text box and one combo box. That is, have one control to set
the number (e.g. "250"), and another control to set the units (e.g. "nano").

Then, whenever you have nano, multiply the figure in the first control
by 10^-9. With Micro, do 10^-6, etc. Assuming you support only "pico",
"nano" and "micro", that means 3 cases in your switch statement.

So if the user enters "250 nF", you take 250, multiply it by 10^-9, and
get an in memory value whose string representation may be any of "250 *
10^-9", "25 * 10^-8", "2.5 * 10^-7", or something else.

- Oliver

Apr 14 '06 #3

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

Similar topics

12
by: François | last post by:
Hi, After looking up Microsoft's site for licensing info...and found nothing, I turn to this newsgroup. Does someone know what version of VB .Net you are entitled to use when you are a micro...
383
by: John Bailo | last post by:
The war of the OSes was won a long time ago. Unix has always been, and will continue to be, the Server OS in the form of Linux. Microsoft struggled mightily to win that battle -- creating a...
13
by: webzila | last post by:
Hello, I have to write a program for an 8051 micro-controller using micro-C to monitor Switch 1 and if the switch in pushed the message "switch 1 pushed" should be displayed in the LCD. Also the...
1
by: Ferdy.Bonvo | last post by:
Dear lovely moderator, please allow me to spread this information, somebody might need it, please forgive me if you are bothered Dear All, this might be useful for you and your family I have...
0
rsrinivasan
by: rsrinivasan | last post by:
Hi, I have to present a seminor on "Nano Technology". I need good site for this. If anybody know about this, please help to me. Thanks,
12
by: howa | last post by:
any side effect for PHP? what do you think?
1
by: Bruce Frederiksen | last post by:
I wanted to make everybody aware that I've posted a (rather long and involved) PEP proposal for adding micro-threading to Python on python-ideas for feedback and review. In a nutshell, this...
1
by: chandramanikanth | last post by:
hi this is chandramani, "i need to read the digital data comminng from the medichair which is embedded with multiple sensors. the stream of data coming from the usb...
8
intruderX
by: intruderX | last post by:
When programing robots with java, how they program hardware with java? Can java do the port programming? Or it is done in some other way? for an example... 1). A basic O/S is running to work with...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.