Miles to Kilometers

What am I doing wrong
import java.util.Scanner;
public class MilesToKm{
public static void main(String[] args){
float miles, conversion;
Scanner scan;
scan = new Scanner (System.in);
System.out.println("Please enter number of miles: ");
miles = scan.nextFloat();
conversion = miles * 1.609;
System.out.println("The number of miles in kilometers is: " + conversion +".");
im getting
MilesToKm.java:13: possible loss of precision
found : double
required: float
conversion = miles * 1.609;
^
1 error
----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complete.

Any floating point literal--e.g. 1.609--is of type double.
Any calculation that contains a double yields a double result.
So it's as if you did this:
double d = 1.234;
float f = d;You can't stuff a double into a float. If you want to do that assignment, you need to cast:
float f = (float)d;  // EDIT: Oops, was double in the cast, should've been float. Thanks warnerja.However, you're better off just using double throughout. There's no reason to use float at all.
Edited by: jverd on Jan 29, 2009 1:20 PM

Similar Messages

  • How do I change the settings in Maps from miles to kilometers?

    How do I change the settings in Maps from miles to kilometers?

    I've had an entirely different experience with Map units.  Maps on my iPad (iOS 8) will only deliver units in kilometers, no matter how I adjust the settings for Maps or Region/Language.  I am trying to calculate distances between two locations in the United States where all road distances are measured in miles.  My iPad region is set to United States.  When I open the settings for Maps, change the units from kilometers to miles, and close the window, IOS-8 changes the setting back to kilometers every time.
    Slick interfaces and device designs aside, at times these little annoying bugs just make the folks at Apple look like rank amateurs.

  • Miles vs Kilometers on voice update

    Cant get my ipod to advise miles vs kilometers during the distance updates during my run. Have the nano set for miles is there a way to fix this?

    Hey 1025KSP,
    If you are using a specific distance workout (ie 3k 5k 10k), the iPod will only give you your distance in km.
    If you are not then go to the Nike+ settings menu and change the distance setting to miles.
    Hope this helps,
    Fred

  • Miles to kilometers in Map

    Hello,
    how I can switch miles to kilometers in rout calculation?

    System Preferences:
    thunderzzz's suggestion is better, as it is not global.

  • Miles, not kilometers?

    When I set my iPod nano & Nike+ to display in miles, why does the display and the resulting workout data reflect as kilometers? How do I correctly set my iPod Nano & Nike + to display miles only? Thanks to one and all.

    Im sure you did a restart with the issue happening again. The next thing to try is a partial erase. If that does not resolve the issue you could try the webOS doctor on your phone. That should correct any code crossing that may have happened.

  • Miles vs. kilometers

    After 3 years of solid performance, suddenly my nano/nikeplus will only measure in kilometers. I keep changing the settings to record in miles (and the display on screen says it is measuring in miles), but the spoken feedback and the display during a run is in kilometers. When I upload my workout to the Nike Plus website, however, it converts to miles. Any thoughts?

    Have you tried restoring the iPod in iTunes? If it's a software issue on the iPod, this will often fix it.

  • How do I convert the MAP app from meters to miles?

    In MAPS, how do I convert from meters to miles?

    Hi willardfromaustin,
    If you are having issues with the distance scale in Maps, you may find the following article helpful:
    Tip: The scale guide in Maps uses the regional measurement preferences (miles or kilometers) you set in the Advanced section of the Language & Region settings in System Preferences.
    Mac Basics: Maps app helps you find your destination
    http://support.apple.com/kb/HT5973
    Regards,
    - Brenden

  • How can I see the distance in kilometers?

    HELP!
    I live in Scandinavia. I bought my Nike + iPod in the US and I can't switch from miles to km like it says in the manual. Nothing happens when I press the center button on "distance-miles"...
    Why can't I switch from miles to km like they say in the manual?? Do I have to download anything? I already have the newest version of iPod and iTunes..
    Boasdottir

    Nike+iPod -> Settings -> Distances -> Miles
    This should change Miles to Kilometers. If it doesn't, try restoring your iPod on iTunes or you have a defective one so take it back to the store you bought it and have it exchanged.

  • How can I see the comments in PDF document on Chrome OS?

    Hi, I am trying to view the comments in a PDF document on my Chromebook (Chrome OS). The PDF viewer in Chrome cannot show them (I see only the graphical hints, like yellow background and such). I tried several apps in the Chrome store, but none of them could show the comments in the PDF document. There is an app to comment a PDF file, but it uses a proprietary format, and is incompatible with the comments created by Adobe Acrobat. I also tried to upload the PDF to the Acrobat.com webspace. While it provides an online viewer, even the Acrobat.com webspace viewer does not show the comments . So I am running out of ideas, and still cannot see the comments of the PDF on my Chromebook...
    Is there something obvious I am missing? Is there an app that can show comments on Chromebooks?
    Thank you!
    Claus

    Nike+iPod -> Settings -> Distances -> Miles
    This should change Miles to Kilometers. If it doesn't, try restoring your iPod on iTunes or you have a defective one so take it back to the store you bought it and have it exchanged.

  • Support - or lack of it

    So, I'm a new iMac user - in fact this is probably the first time I have ever used something from Apple since I used a Lisa many years ago.
    I received by 28" iMac towards the end of November. I used it for two days and then had to leave on a business trip. I came back yesterday and realised that there was a strange glow from the LCD panel at the bottom of the screen. I thought, OK, a defective panel - it happens - I'll just call support and get it fixed.
    Wow, what a strange and frustrating experience. I was asked by the support rep to run some disk utilities and repair permissions (***?). I was then asked to unplug everything and press the power key (was this to get rid of static?).
    Suprise, suprise, it didn't make any difference and he then said I would have to return this to an authorised repair centre to get it fixed.
    So, the object of my posting is to ask what alternatives do I have. I looked on the support pages within this site and there is no e-mail address I can use to contact someone to explain why I feel Apple is not ready to enter the corporate computing world.
    Does anyone have any advice for me? I am located in Madrid (just north of it) and this was a company purchase.
    Many thanks in advance,
    Emmet
    Message was edited by: Host

    Good morning Emmet,
    Just to correct you on your On-Site interpretation...
    This comprehensive plan includes expert telephone technical support, global repair coverage, onsite repairs for desktop computers(1)
    If you read a bit further down...
    1. Onsite service is not available in all locations. Please see the Terms & Conditions for details.
    Which delving into the Terms and conditions for your Region...
    (ii) Onsite service is available for many desktop computers if the location of the Covered
    Equipment is within 50 miles/80 kilometers radius of an Apple authorized onsite service
    provider located in a country listed in section 7(d). Apple will dispatch a service technician to
    the location of the Covered Equipment. Service will be performed at the location, or the service
    technician will transport the Covered Equipment to an Apple Authorized Service Provider or
    Apple repair service location for repair. If the Covered Equipment is repaired at an Apple
    Authorized Service Provider or Apple repair service location, Apple will arrange for
    transportation of the Covered Equipment to your location following service. If the service
    technician is not granted access to the Covered Equipment at the appointed time, any further
    onsite visits may be subject to an additional charge.
    (iii) Direct mail-in service is available for most Covered Equipment. If Apple determines that your
    Covered Equipment is eligible for mail-in service, Apple will send you prepaid shipping labels
    (and if you no longer have the original packaging, Apple may send you packaging material) and
    you will ship the Covered Equipment to Apple’s repair service location in accordance with its
    instructions. Once service is complete, the Apple repair service location will return the Covered
    Equipment to you. Apple will pay for shipping to and from your location if all instructions are
    followed.
    So in short, Apple doesn't promise on-site service at any time unless you meet a very specific set of conditions, make sure you read the fine print!
    Please also keep in mind this ONLY applies to AppleCare customers, those who have the extended warranty program, as the on-site mentions all come from the AppleCare pages and guides.
    Hope this helps! 
    David

  • Format Date Form Field in Adobe Acrobat Pro

    Thanks in advance for your help. I have date fields in an Acrobat form. Is it possible to create a script to format a date as either MM/DD/YYYY or MM/DD/YY? In other words, if someone enters MM/DD/YYYY, the date would be accepted and MM/DD/YY would also be accepted. Thanks, again.

    Since the time measurement is based on a sattilite revolving around another object in space, much of the concepts and measurements apply to rocket science. But I do not know if all rocket scientist woudl get it. Wasn't there a sattilite that mixed miles and kilometers within the navigation program with a suprising result.
    One needs to get to a common unit and then just do the math.
    Actually JavaScript does have an adjustment for the Date.getYear if the date object is established with the 4 digit year.
    I had a recent issue at work. I work from the U.S and have to access data on a server in the UK using Remote Desktop and the remote deskto is configured for the UK date format unless the user changes it. In prior years the data was processed on servers in the U.S. with U.S. date format. There were many instances when the date and month were swithed and requires over a month to fix. Thank you Microsoft Certified Network Administrators.

  • Java Interface as problems

    Hi this code for java i am having major problems. I am a newbie to java so please be kind and hope in the feature i can master java and then help to each others. I will include the show GUI class later.
    My main problem is how to assign events to the button so that it preforms a calculation.
    Second what should make my GUI run properly and what actions do i need to take.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class ConvertValues extends JPanel {
    public class ConvertValues {
         JFrame window;
         JComboBox inputcombo,outputcombo;
         JRadioButton Length,Mass,Volume,Temperature;
         JButton = new JButton("Convert");
         JTextField outputtext, inputtext;
         public ConvertValues(){
              window = new JFrame("Imperial to Metric Converter");
              window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              window.setSize(600,600);
              window.setVisible(true);
              addRadioButtons();
              addComboBox();     
              public void addPanel(){
              Public JPanel getPanel();
              JPanel wrapper = new JPanel();
              wrapper.setLayout(new BorderLayout());
              wrapper.setBorder(BorderFactory.createEmptyBorder(13,13,13,13));
              JPanel centre = new JPanel ();
              centre.setLayout(new GridLayout(2,2));
              public void addRadiobButton(){
              JRadioButton RadioButton = new JRadioButton();
              JPanel rbut = new JPanel();
              rbut1.setLayout(new GridLayout(4,4));
              JPanel panel1 = new JPanel();
              JLabel metric = new JLabel (" Length Metric Values")
              panel1.add(metric);
              rbut1.add (panel1);
              JPanel panel2 = new JPanel();
              JTextField text1 = new JTextField (13);
              panel2.add(text1);
              rbut1.add(panel2);
              JPanel panel3 = new JPanel();
              JLabel imperial = new JLabel ("Length Imperial Values")
              panel3.add(Imperial);
              rbut1.add (panel3);
              JPanel panel4 = new JPanel();
              JTextField text2 = new JTextField (13);
              panel4.add(text2);
              rbut1.add(panel4);
              JPanel rbut2 = new JPanel();
              rbut2.setLayout(new GridLayout (4,4));
              JPanel panel5 = new JPanel ();
              JLabel metric2 = new JLabel ("Liquid Metric Values");
              panel5.add(metric2)
              rbut2.add(panel5);
              JPanel panel6 = new JPanel ();
              JTextField text3 = new JTextField (13);
              panel6.add(text3);
              rbut2.add(panel6);
              JPanel panel7 = new JPanel ();
              JLabel imperial2 = new JLabel ("Liquid Imperial Values");
              panel5.add(imperial2)
              rbut2.add(pane7);
              JPanel panel8 = new JPanel ();
              JTextField text4 = new JTextField (13);
              panel8.add(text4);
              rbut2.add(panel8);
              JPanel rbut3 = new JPanel();
              rbut3.setLayout(new GridLayout (4,4));
              JPanel panel9 = new JPanel ();
              JLabel metric3 = new JLabel (" Mass Metric Values");
              panel9.add(metric3)
              rbut3.add(panel9);
              JPanel panel10 = new JPanel ();
              JTextField text5 = new JTextField (13);
              panel10.add(text5);
              rbut3.add(panel10);
              JPanel panel11 = new JPanel ();
              JLabel imperial3 = new JLabel ("Mass Imperial Values");
              panel11.add(imperial3)
              rbut3.add(pane11);
              JPanel panel12 = new JPanel ();
              JTextField text6 = new JTextField (13);
              panel12.add(text6);
              rbut3.add(panel12);
              JPanel rbut4 = new JPanel();
              rbut4.setLayout(new GridLayout (4,4));
              JPanel panel13 = new JPanel ();
              JLabel metric4 = new JLabel (" Temperature Metric Values");
              panel13.add(metric4)
              rbut4.add(panel13);
              JPanel panel14 = new JPanel ();
              JTextField text6 = new JTextField (13);
              panel14.add(text6);
              rbut4.add(panel14);
              JPanel panel15 = new JPanel ();
              JLabel imperial4 = new JLabel ("Temperature Imperial Values");
              panel15.add(imperial4)
              rbut4.add(pane15);
              JPanel panel16 = new JPanel ();
              JTextField text7 = new JTextField (13);
              panel16.add(text7);
              rbut4.add(panel16);
              radiopanel.add("Length","rbut1")
              radiopanel.add("Liquid Mass","rbut2")
              radiopanel.add("Mass","rbut3")
              radiopanel.add("Temperature","rbut4")
              public void addComboBox(){
              JPanel panel17 = new JPanel();
              String[] str = {"Milliimeters", "Centimeters", "Meters", "Kilometers"};
              JComboBox metricvalues = newJComboBox(str);
              panel17.add(metricvalues);
              rbut1.add(panel17);
              JPanel panel18 = new JPanel();
              String[] str2 = {"Inch", "Foot", "Yard", "Mile"};
              JComboBox imperialvalues = newJComboBox(str2);
              panel18.add(imperialvalues);
              rbut1.add(panel18);
              JPanel panel19 = new JPanel();
              String[] str3 = {"Litres", "Millilitres", "Litres"};
              JComboBox metricvalues = newJComboBox(str3);
              panel19.add(metricvalues);
              rbut2.add(panel19);
              JPanel panel20 = new JPanel();
              String[] str4 = {"Fluid", "Ounce", "Pint", "Quart", "Gallon"};
              JComboBox imperialvalues = newJComboBox(str4);
              panel20.add(imperialvalues);
              rbut2.add(panel20);
              JPanel panel21 = new JPanel();
              String[] str5 = {"Grammes", "Kilogrammes", "Metric Tonne"};
              JComboBox metricvalues = newJComboBox(str5);
              panel21.add(metricvalues);
              rbut3.add(panel21);
              JPanel panel22 = new JPanel();
              String[] str6 = {"Ounce", "Pound", "Stone", "Long Ton"};
              JComboBox imperialvalues = newJComboBox(str6);
              panel22.add(imperialvalues);
              rbut3.add(panel22);
              JPanel panel23 = new JPanel();
              String[] str6 = {"Grammes", "Kilogrammes", "Metric Tonne"};
              JComboBox metricvalues = newJComboBox(str6);
              panel23.add(metricvalues);
              rbut4.add(panel23);
              JPanel panel24 = new JPanel();
              String[] str7 = {"Ounce", "Pound", "Stone", "Long Ton"};
              JComboBox imperialvalues = newJComboBox(str7);
              panel24.add(imperialvalues);
              rbut4.add(panel24);
              frame.getContentPane().add(center, BorderLayout.CENTER);
              public void addLabelandtext();{
              inputlabel = new JLabel("Enter Value");
              valuelabel = new JLabel("0");
              metricLabel = new JLabel ("Metric Value");
              imperial value = new JLabel("Imperial Value");
              outputtext = new JTextField(8);
              inputtext = new JTextField (8);
              JPanel labelpanel = new JPanel();
              labelpanel.add(inputlabel);
              labelpanel.add(mJPanel panel25 = new JPanel();
              labelpanel.add(imperiallabel);
              labelpanel.add(valuelabel);
              labelpanel.add(outputtext);
              labelpanel.add(inputtext);
              JPanel top = new JPanel(new GridLayout(5,3));
              middle.add(labelpanel);
              frame.getContentPane().add(middle,BorderLayout.SOUTH);
              public void ConvertButton();{
                   JPanel panel25 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel25.add(convert);
                   rbut1.add(panel 25));
                   JPanel panel26 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel26.add(convert);
                   rbut2.add(panel 26));
                   JPanel panel27 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel27.add(convert);
                   rbut3.add(panel 27));
                   JPanel panel28 = new JPanel();
                   JButton convert = new JButton ("CONVERT");
                   Convert.addActionListener(this);
                   panel28.add(convert);
                   rbut4.add(panel 28));
              public void LengthConverter();{
              Let measurement = TextIO.getDouble()
              Let units = TextIO.getlnword();
              if the units are inches
                   Let inches = measurement
              else if the units are milimeters
                   Let inches = measurement*25.4
              else if the units are Foot
                   Let centirmeter = measurement*30.48
              else if the units are Yard
                   Let meter = measurement*0.9144
              else if the units are mile
                   let kilometers = measurement*1.609
              else if the unit are meters
                   let centimeters = measurement*100
              else
                   The units are wrong!
                   Print an error message and stop processing
              let milimeter = inches/25.4
              let foot = centimeters/30.48
              let Yard = meter/0.9144
              let mile = kilometers/1.609
              let meter = centimeter/100
              dispay the results
              public void VolumeConverter();{
                   Let measurement = TextIO.getDouble()
              Let units = TextIO.getlnword();
              if the units are Fluid Ounce
                   Let Fluid Ounce = measurement
              else if the units are mililitres
                   Let Fluid Ounce = measurement*28.41
              else if the units are Pint
                   Let Litres = measurement*0.568
              else if the units are Quart
                   Let Litres = measurement*1.14
              else if the units are Gallon
                   let litres = measurement*4.54
              else if the unit are litres
                   let centilitres = measurement*100
              else
                   The units are wrong!
                   Print an error message and stop processing
              let mililitres = Fluid Ounce/28.4
              let Pint = Litres/0.568
              let Quart = Litre/1.14
              let Gallon = Litres/4.54
              let litre = centilitre/100
              dispay the results
              public void WeightConverter();{
                   Let measurement = TextIO.getDouble()
              Let units = TextIO.getlnword();
              if the units are Ounce
                   Let Ounce = measurement
              else if the units are Grammes
                   Let Ounce = measurement*28.35
              else if the units are Pound
                   Let kilograms = measurement*0.4536
              else if the units are Stone
                   Let Kilogrammes = measurement*6.3503
              else if the units are Longton
                   let metric tonne = measurement*1.016
              else if the unit are Gramme
                   let Killogram = measurement*100
              else
                   The units are wrong!
                   Print an error message and stop processing
              let Gramme = Ounce/28.35
              let Pound = Kilogram/0.4536
              let Stone = Killogrammes/6.3503
              let Longton = metrictonne/1.016
              let Gramme = Kilogram/100
              dispay the results
              private static void createAndShowGUI();{
                   ConvertValues newScreen = new ConvertValues();
         }

    My main problem is how to assign events to the button so that it preforms a calculation. [url http://java.sun.com/docs/books/tutorial/uiswing/components/button.html]How to Use Buttons
    Also, use the "Code Formatting Tags" when posting code so it retains its original formatting and is readable.

  • Wifi Design Help

    Hi,
    I have one branch,100m away from my HQ. Hq is equiped with cisco devices.
    There is no cabling in brach office. How can i connect any 1 floor of my branch to my HQ using cisco wifi devices with maximum range???

    You can connect your branch office to head office through outdoor access point. It Data rates of 54 Mbps in the 2.4-GHz band, Bridge range of 20 miles (32 kilometers [km]) at 11 Mbps, Aggregate throughput approaching 28 Mbps, Maximum transmit power of 100 milliwatts (mW) for 802.11b and 30 mW for 802.11g.
    The Cisco Aironet 1300 Series supports 802.11i, Wi-Fi Protected Access 2 (WPA2), WPA, and numerous Extensible Authentication Protocol (EAP) types. WPA and WPA2 are the Wi-Fi Alliance certifications for interoperable, standards-based WLAN security.

  • Can you have code run in a terminal and applet?

    For example in my program in Main we enter the data for menu and amount of the exchange but the result is displayed in an applet.
    works great in the terminal window.
    but when using an applet it will not work.
    import java.awt.*;
    import java.applet.*;
    import javax.swing.* ;
    import TerminalIO.*;
    public class MetricConversionMain    {
             final static String CRLF = "\n" ;     
             static String msgOut ;                   
         public static void main ( String[] args )     {
            int valid  = 0;
            int choose = 0;
            double numUnits = 0.0; 
            double convertedUnits = 0.0;
                                  // title, class, author and version info  to
         KeyboardReader entries = new KeyboardReader(); //object for keyboard entry
         while (valid != 1) {
                // menu for conversion selection 1 thru 4          
         System.out.println("\n\t\t1 \tFor inches to centimeters");
          System.out.println("\t\t2 \tFor quarts to liters");
          System.out.println("\t\t3 \tFor pounds to kilograms");
          System.out.println("\t\t4 \tFor miles to Kilometer");
              choose = // GW corrected my code to the present prior I was choose = choose.readInt etc etc
            entries.readInt("\n\t\tPlease choose one of the following menu items to convert: ");
          if (choose == 1 || choose == 2 || choose == 3 || choose ==4 ) {
               valid = 1 ;
          else {
               System.out.println("Invalid Selection.") ;
          switch (choose) {
              case 1 : System.out.println("Converting inches to centimeters... ") ; break ;
              case 2 : System.out.println("Converting quarts to liters... ") ; break ;
              case 3 : System.out.println("Converting pounds to kilograms... ") ; break ;
              case 4 : System.out.println("Converting miles to kilometers... ") ; break ;
         } // Error checking, reiterates the user's current choice prior to next question
         System.out.println();
         KeyboardReader useEntry = new KeyboardReader(); //object for keyboard entry
              numUnits =
            useEntry.readDouble("\n\t\tNow please enter the amount you wish to convert: ");
              System.out.println ("\t\tThe conversion comes to  " + numUnits);
         //KeyEntry equal = new KeyEntry();   
         //equal.setNumUnits
        //(useEntry.readDouble("\n\t\tNow please enter the amount you wish to convert: "));
         //System.out.println("\t\tThe conversion comes to  " + getnumUnits());
         switch (choose) {
              case 1 : Inch fromInch = new Inch(numUnits); break ;}
         case 2 : Quart fromQuart = new Quart(numUnits) ; break ;
              /*     case 3 : Pound fromPound = new Pound( numUnits) ; break ;
              case 4 : Mile fromMile = new Mile(numUnits) ; break ;
         } // Switch statement that performs the correct conversion based on the user's input*/
                   // Instantiate US Standard Objects
         /*     Inch fromInch = new Inch(1) ;
              Foot fromFoot = new Foot(1) ;
              Yard fromYard = new Yard(1) ;
              Mile fromMile = new Mile(1) ;
              Ounce fromOunce = new Ounce(1) ;
              Quart fromQuart = new Quart(1) ;
              Gallon fromGallon = new Gallon(1) ;
              Pound fromPound = new Pound(1) ;
              // Instantiate Metric Objects          
              Centimeter fromCentimeter = new Centimeter(1) ;
              Meter fromMeter = new Meter(1) ;
              Kilometer fromKilometer = new Kilometer(1) ;
              Gram fromGram = new Gram(1) ;
              Liter fromLiter = new Liter(1) ;
              Kilogram fromKilogram = new Kilogram(1) ;
              LitGal fromLitGal = new LitGal(1) ; */
         }     //  main
    }     //     class MetricConversionMainsupper classpublic class SuperConverter        {
         *     This class is the super class for a series of
         *     subclasses that perform conversion from metric to
         *     imperial or vice versa.
         protected double numUnits ;
         protected double convertedUnits ;
         protected double factor ;
         // Constructor
         public SuperConverter ( double argNumUnits, double argFactor )  {     
         numUnits = argNumUnits ;
         factor = argFactor ;
         convertedUnits = numUnits * factor ; //convert() ;
         }     // Constructor
         protected double getnumUnits()     {
              return numUnits ;
         protected void setnumUnits     ( double argNumUnits )     {
              numUnits = argNumUnits ;
         protected double convert  () {
              this.convertedUnits = numUnits * factor ;     
              return convertedUnits ;     
         public double getconvertedUnits()     {
              this.convertedUnits = convert() ;
              return convertedUnits ;
    }     //  end SuperConverter Classsubclass that works[public class Inch extends SuperConverter {
         public Inch      (double argNumUnits)
              super ( argNumUnits, 0.914 ) ;
              System.out.print   ("     ") ;
         if (argNumUnits > 1)
                   System.out.println(argNumUnits + " inches = " + convertedUnits + " centimeters") ;
              else
                   System.out.println(argNumUnits + " inch = " + convertedUnits + " centimeters") ;
    /code]
    The code I want to use  with the applet is import java.awt.*;
    import java.applet.*;
    import javax.swing.* ;
    public class Inch extends SuperConverter {
         final static String CRLF = "\n" ;     
         static String msgOut ;          
         public Inch      (double argNumUnits)
              super ( argNumUnits, 2.54 ) ;
              System.out.print ("     ") ;
              if (argNumUnits > 1)
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;
              msgOut += "     US Standard to Metric" + CRLF ;
         msgOut += "     -------------------------------------------------" + " " + CRLF ;
                   msgOut = argNumUnits + " inches = " + convertedUnits + " centimeters" ;
              else
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;
              msgOut += "     US Standard to Metric" + CRLF ;
         msgOut += "     -------------------------------------------------" + " " + CRLF ;
                   msgOut += argNumUnits + " inch = " + convertedUnits + " centimeters" + CRLF + CRLF + CRLF ;
              }     JOptionPane.showMessageDialog ( null, msgOut ) ;          
    }

    The issue I have is the applet/window appears behind the terminal window. below is the code that is use for the window. I want to have the window appear infront of the terminal window.import java.awt.*;
    import java.applet.*;
    import javax.swing.* ;
    public class Pound extends SuperConverter {
        final static String CRLF = "\n" ;     
             static String msgOut ;     
         public Pound      (double argNumUnits)
              super ( argNumUnits, 0.454 ) ;     
              System.out.print   ("     ") ;     
              if (argNumUnits > 1)
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;             
                  msgOut +=  "     Metric to US Standard" + CRLF ;
                  msgOut +=  "     -------------------------------------------------" + "         " + CRLF ;
                   msgOut += argNumUnits + " pounds = " + convertedUnits + " kilograms" + CRLF + CRLF + CRLF ;
              else
              {   msgOut = "     Metric Conversion Chart" + CRLF + CRLF;
                  msgOut +=  "     Metric to US Standard" + CRLF ;
                  msgOut +=  "     -------------------------------------------------" + "         " + CRLF ;
                   msgOut += argNumUnits + " pound = " + convertedUnits + " kilograms" + CRLF + CRLF + CRLF ;
              }   JOptionPane.showMessageDialog ( null, msgOut ) ;
    }

  • Perform grep search

    Hi folks,
    I was wondering whether it was possible to find and replace using grep. I have the find and replace thing sorted, but I need it to be flexible enough to select any number and alter the value by a set amount. I have done this in InDesign but have become stuck with Illustrator.
    I have tried to use an adapted version of the search script from this thread: (CarlosCanto)
    var multiplier = parseFloat(2.5);
    var search_string = /[-]*[0-9][0-9,.]*\\b/gi;
    var replace_string = search_string * multiplier;
    var text_frames = active_doc.textFrames;
    if (text_frames.length > 0) {
        for (var i = 0 ; i < text_frames.length; i++) {
            var this_text_frame = text_frames[i];
            var new_string = this_text_frame.contents.replace(search_string, replace_string);
            if (new_string != this_text_frame.contents) {
                this_text_frame.contents = new_string;
    This simply returns 'undefined'
    Do I need to invoke a grep function to parse the pattern through?
    Any help would be wonderful.
    Thanks

    This is what I meant by using UnitValues…
    #target illustrator
    var idoc = app.activeDocument;
    var ilayer = idoc.layers['measurements'];
    var oldUnit = prompt ( 'Enter old unit string:', 'inch', 'Convert Units' );
    var newUnit = prompt ( 'Enter new unit string:', 'mm', 'Convert Units' );
    for ( var i = 0; i < ilayer.textFrames.length; i++ ) {
         var itext = ilayer.textFrames[i].contents;
         var mValue = new UnitValue( Number( itext ),oldUnit );
         ilayer.textFrames[i].contents = mValue.as( newUnit );
    If you were to look up the strings table you will see yards, miles, meters, kilometers etc… Plus all the usual stuff just a little less math for you to input… Personally I would still use a dialog with 2 drop down lists for old & new units… That should be simple enough to do…

Maybe you are looking for