473,805 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9317
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.BigDe cimal 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********@hot mail.com> wrote in message
news:gy******** ***********@new s20.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
2619
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 business? I think I can't buy a VB .Net standard edition but I'm not sure about it. Also if I need to buy VB .Net Enterprise, how many licenses come with this, one only?
383
12284
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 poor man's DBMS, a broken email server and various other /application/ servers to try and crack the Internet and IS markets. In the case where they didn't spend their own money to get companies to
13
6221
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 microcontroller should display in the LCD the value of the voltage applied to the input of the ADC. The above procedure should only execute once the user has entered "1234" using a keypad that is attached to the 8051 microprocessor.
1
1741
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 already use it and prove that my family health is now very much improve,no more headache, no more back pain, no more 'night owl' to get better sleep,and help my autism brother to be more calm and easy to handle, perhaps it may help others with...
0
967
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
1826
by: howa | last post by:
any side effect for PHP? what do you think?
1
1772
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 proposal implements the Twisted Deferred/Reactor at the C level so that the Python programmer gets the advantages that Twisted offers without having to write their code in an event driven style. Thus, legacy Python code not written in the Twisted...
1
13275
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 will be sent by a micro controller based system in the chair and "need to receive the data constantly when the chair is in use and sort out the data into categories of weight, temp, bp, ecg, heart and pulse rates. " etc .programming language.need to...
8
2719
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 hardware. 2). JVM runs on that O/S. 3). A Java program is running on the JVM, and it(JAVA) is used for the programming, as it become more user friendly to the programmers. I need to know whether we can program hardware with just JAVA, without...
0
9596
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
10614
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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
10369
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
10109
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
9186
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
7649
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...
1
4327
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
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.