How can make it work? how to correct the coding?

// my first lesson
import javax.swing.JOptionPane;
public class Product {
public static void main( String args[] )
int x, y, result;
String xCode, yQty;
     int FreeHand, Flash, Director;
     FreeHand = 10;
     Flash = 20;
     Director = 30;
xCode = JOptionPane.showInputDialog(
"Enter the product name we offer: FreeHand, Flash, Director" );
yQty = JOptionPane.showInputDialog(
"Pls enter the quantity:" );
x = Integer.parseInt( xCode );
y = Integer.parseInt( yQty );
price = x * y;
JOptionPane.showMessageDialog( null,
"Thanks, total purchase is" + price );
System.exit( 0 );

// my first lesson
import javax.swing.JOptionPane;
public class Product {
public static void main( String args[] )
int x, y, result;
String xCode, yQty;
       int FreeHand, Flash, Director;
       FreeHand = 10;
       Flash = 20;
       Director = 30;
xCode = JOptionPane.showInputDialog(
"Enter the product name we offer: FreeHand, Flash, Director" );
yQty = JOptionPane.showInputDialog(
"Pls enter the quantity:" );
x = Integer.parseInt( xCode );
y = Integer.parseInt( yQty );
price = x * y;
JOptionPane.showMessageDialog( null,
"Thanks, total purchase is" + price );
System.exit( 0 );
Well it doesn't work. You parse the input from the first JOptionPane as if it is an int, but it should be a String - "FreeHand", "Flash" etc.
Also in your original message the first String was declared over two lines - you can't do this! Either declare on one line or break up into substrings and use the "+" operator.
How about.
import javax.swing.JOptionPane;
import java.util.*;
public class Product {
    public static void main( String args[] )
       int x, y, result;
       String xCode, yQty;
       //New product Map
       Map products = new HashMap();
       products.put("FreeHand", new Integer(10));
       products.put("Flash", new Integer(20));
       products.put("Director", new Integer(30));
       xCode = JOptionPane.showInputDialog(
                 "Enter the product name we offer: "
                   + "FreeHand, Flash, Director" );
       yQty = JOptionPane.showInputDialog(
                 "Pls enter the quantity:" );
       x = ((Integer)map.get(xCode)).intValue();
       y = Integer.parseInt( yQty );
       price = x * y;
       JOptionPane.showMessageDialog(
          null,
          "Thanks, total purchase is" + price );
       System.exit( 0 );

Similar Messages

  • To turn on my ipod, I get an image of connection to iTunes, but when you update iTunes, nothing happens. I restarted the iPod manually several times peero still appears the same image. how I can make it work?

    to turn on my ipod, I get an image of connection to iTunes, but when you update iTunes, nothing happens. I restarted the iPod manually several times peero still appears the same image. how I can make it work?

    Restore the ipod

  • TS1559 I stop receiving I message in my iPad recently I changed my apple password how can make it work again?

    I stop receiving I message in my iPad recently I changed my apple password how can make it work again?

    Using FaceTime http://support.apple.com/kb/ht4319
    Troubleshooting FaceTime http://support.apple.com/kb/TS3367
    The Complete Guide to FaceTime + iMessage: Setup, Use, and Troubleshooting
    http://tinyurl.com/a7odey8
    Troubleshooting FaceTime and iMessage activation
    http://support.apple.com/kb/TS4268
    iOS: About Messages
    http://support.apple.com/kb/HT3529
    Set up iMessage
    http://www.apple.com/ca/ios/messages/
    Troubleshooting Messages
    http://support.apple.com/kb/TS2755
    Setting Up Multiple iOS Devices for iMessage and Facetime
    http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l
    FaceTime and iMessage not accepting Apple ID password
    http://www.ilounge.com/index.php/articles/comments/facetime-and-imessage-not-acc epting-apple-id-password/
    Unable to use FaceTime and iMessage with my apple ID
    https://discussions.apple.com/thread/4649373?tstart=90
     Cheers, Tom

  • I bought the pack for students adobe creative cloud, already made the payment three days ago but when opening programs like photosop and illustrator puts the trial period has expired, how I can make them work?

    I bought the pack for students adobe creative cloud, already made the payment three days ago but when opening programs like photosop and illustrator puts the trial period has expired, how I can make them work?

    Hello Ibonedm,
    Sol 1. Please try sign out from Creative cloud Desktop App and quit it.
    1. Launch Creative Cloud application manager.
    2. Click the gear icon in the upper-right corner and select Preferences.
    3. In the Preferences menu, under General, click the Account tab.
    4. Click Sign Out from Creative Cloud.
    Then re-sign in and launch Photoshop CC 2014 and check.
    Sol 2. Check your Hosts file.
    Windows
    1. Choose Start > Run, type %systemroot% \system32\drivers\etc, and then press Enter.
    2. Locate Hosts file and move it to Desktop
    3. Right-click the hosts file and select Open. Select Notepad for the application to open the hosts file.
    4. Back up the hosts file: Choose File > Save As, save the file as hosts.backup, and then click OK.
    5. Search the hosts file for entries that reference activate.adobe.com (for example, 127.0.0.1 activate.adobe.com) and delete these entries.
    6. Save and close the file and move it back to Etc folder.
    Mac OS
    1. Log in as an administrator to edit the hosts file in Mac OS.
    2. In a Finder window, choose Go > Go To Folder.
    3. Type /etc.
    4. Select the hosts file and move it on Desktop  open it.
    5. Back up the hosts file: Choose File > Save As, save the file as hosts.backup, and then click OK.
    6. Search the hosts file for entries that reference activate.adobe.com (for example, 127.0.0.1 activate.adobe.com) and delete these entries.
    7. Move Hosts file back to etc folder
    8. Save and close the file.
    Then try launching Photoshop CC 2014 or Illustrator CC 2014
    If prompt for License this software, please click on it and sign in with the Adobe ID and Password which you have used to purchase the subscription and check if you can activate and use the products.
    Please respond , if any issue.
    All the best
    Loveneesh.

  • I've tried downloading iOS5 several times and after an hour each time I get a message that says my network connection has timed out.  But I can't find any information about "timing out" or how to correct the situation.  Any help?

    I've tried downloading iOS5 several times and after an hour each time I get a message that says my network connection has timed out.  But I can't find any information about "timing out" or how to correct the situation.  Any help?

    Disable your antivirus and firewall, and try again.

  • I can't sign into Mozilla Foxfire the messages say crash I send the Crash Report, and look a detail, but not should were the crash started and how to correct the problem.

    I can't upload Mozilla Foxfire internet, an error message shown Crash, I sent the crash report but not happen. Also look at the crash report detail, I'm should were the crash started and don't no how to correct the problem
    == This happened ==
    Every time Firefox opened
    == may 18 2010 ==
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; (R1 1.6); InfoPath.2; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

    Firefox will not open. I have the message "Firefox crashed" and a statement that Firefox will restore my tabs and send me a message, neither of which has happened.

  • How to correct the birth date in Apple account? How to change the numerals to English for UAE location?

    I purchased iPhone 5S and opened new Apple account with preffered language English and location UAE. I was directed to enter my birth date with only Arabic language option. There was no way to change the language or skip the step. I had to enter an arbitrary birth date to go to the next step. How to correct the birth date now and change the numerals to English?

    Solution!!
    I was finally able to get the installer build to work, even though it takes about ten minutes!!  The network and CPU activity is minimal, so I don't know what LV is waiting on during all this time?
    For this installation it appears to be related to the directory structure created by the Volume License Manager 2.1 software.  There are two sets of users at my company, LabVIEW Professional and Developer Suite, which have different license numbers and installers.  The errors were related to source files located in the Products folder of the network distribution.  My installation expected the Products folder to be in a different location that it was actually placed by the VLM software.  I copied the entire Products folder from _SourceFiles up to the LabVIEW 8.5.1 folder and now it works, although very slowly.
    LabVIEW 8.5.1
    -->_SourceFiles
        -->Bin
        -->Device Drivers
        -->Licenses
        -->Products   (original location)
        -->Signal Express
    -->Dev Suite
    -->LV Pro
    -->Products    (manual copy)
    I hope this information may be of use to NI or other users.
    Message Edited by jrjones on 08-12-2008 03:21 PM
    Message Edited by jrjones on 08-12-2008 03:23 PM

  • I am traveling in Chile, South America. I purchased an Entel sym card and I can make and receive phone calls, but the internet only works on WiFi. Do I need to region unlock or what? I willl only be here for A month and a half so I don't want to buy a pho

    I am traveling in Chile, South America. I purchased an Entel sym card and I can make and receive phone calls, but the internet only works on WiFi. Do I need to region unlock or what? I willl only be here for A month and a half so I don't want to buy a phone. Any suggestions?

    Most of the current Apple Intel based computers are comparable in CPU speed. I don't think it is so much the model of laptop as it is the memory, and storage capacity of the machine. If you are going to use FCP on a regular basis, perhaps as a professional or semi-professional, then you should think about the maximum memory and a very large capacity internal disk drive. For instance, one hour of finished compressed video will take up about 1.5 to 2Gbytes of disk space. If you add up the raw footage and still imagery and audio, you'll use up your disk drive capacity real quick. So a hard disk on the order of 750Gbytes @ 7200rpms might be good for video editing. 5400RPMs might be slow to rendering times. Rendering a video might take up a lot of memory so more memory is better e.g. 8Gbytes.
    As a rule of thumb, once you get to about 80% of your disk drive or memory you'll see degradation of performance.
    You can check out macsales.com. THey have a menu system that will allow you to pick and choose from various alternatives. BTW, it's been said that although Macs are typically spec'd at a certain memory size, macsales.com found that Apple computers will actually support higher memory levels. That is, if 4Gbytes are spec'd, some machines support 6Gbytes. macsales.com will provide the guidance for you.
    You might also consider buying an external disk e.g. 500Gbytes to carry around with you for back-up or transport to another machine.

  • Hi - I created a form in Adobe Livecycle and have a button on it to send the form via email.  t worked, but only for those with PC.  I could not get it to work with Apple Yosemite even with reader installed .  is there a way i can make it work for apple /

    Hi - I created a form in Adobe Livecycle and have a button on it to send the form via email. It worked, but only for those with PC. However,  I could not get it to work with Apple loaded with Yosemite even with reader installed .  Is there a way i can make it work for apple / Mac? It worked fine on a mac using Mountain Lion and reader
    Thanks

    LiveCycle = XFA forms.
    afaik - These cannot be used in Apple OSs.
    Be well...

  • Every time I download a file to my macbook pro, it saves it to downloads but changes the name and inserts % sign.  Please advise how to correct the name that it is saved under.

    Every time I download a file to my macbook pro, it saves it to downloads but changes the name and inserts % sign.  Please advise how to correct the name that it is saved under.

    Anything Downloaded with a Particular Apple ID is tied to that Apple ID and Cannot be Merged or Transferred to a Different Apple ID.
    Apple ID FAQs
    http://support.apple.com/kb/HE37

  • I have a generation 3 ipod 80 gig.  When I updated itunes to 11.1.11 and tried to sync the ipod it erased it and now wont recognize it.  I can't seem to make this work  I have reset the ipod, reloaded itunes all to no effect.  Any ideas?

    I have a generation 3 ipod 80 gig.  When I updated itunes to 11.1.11 and tried to sync the ipod it erased it and now wont recognize it.  I can't seem to make this work  I have reset the ipod, reloaded itunes all to no effect.  Any ideas?

    Here is what worked for me:
      My usb hub, being usb2, was too fast. I moved the wire to a usb port directory on my pc. That is a usb1 port which is slow enough to run your snyc.

  • I am trying to rent a movie on my Apple tv keep getting the message - verification required before you can make purchases you must go to the itunes store on your computer and verify your payment information

    Hi  I am Del
    I am trying to rent a movie on my Apple tv keep getting the message - verification required before you can make purchases you must go to the itunes store on your computer and verify your payment information
    Thanks

    Have you paired your Apple Tv with your iTunes account?  That's how rentals and purchases are billed.  If, however, you have already done that it is possible that there is a glitch in the system.  I've had that happen occasionally and it usually goes away if I reset Apple Tv.  On one occasion that I didn't work so I had to go to iTunes and deauthorize and then authorize this computer.  Also, check to see if your Home Sharing is on (under File in iTunes).  Hope that helps.

  • How to being the coding inside an inbound proxy class for a given structure

    Hi.
    i have been assigned a task to write a code to post a GL for which i am using a BAPI but as the mapping is done in XI the structure has been provided, where the structure in nested in first table type and then line type and above all the proxy structure, so i was wondering how would i start with the coding part as it would have been easy if i had to access the structure directly from the DB table but now i have to make use of the structure provided by XI.
    can any one help to start with the coding logic, where in afterwards in can implement the rest of the logic myself,
    Thanks in advance,
    Robert.

    You should run an application in the "debug" mode. Just put "&analyze=X" at the end of the PCUI application' URL in the browser.
    Sometimes it's necessary to turn off buffering:
    • Call up the 'User maintenance' transaciton (SU01)
    • Call up the change mode for the desired user
    • Go to the 'Parameters' tab
    • Create parameter CRM_URL_BUFFER_OFF if this does not exist
    • Enter parameter value 'X' for parameter CRM_URL_BUFFER_OFF
    • Save

  • How to modify the coding part of KE30 reports ?

    How to modify the coding part of KE30 reports ,
    so that I can be able to restrict report output based on sales office.
    I am unable to find out the program name also.
    Regards
    Anubhav

    >
    Venkat Reddy wrote:
    > Hi,
    >
    > If u want to know the program running for KE30 just go to SE93 and give KE30
    > and click on display you can see the program running for KE30 will be SAPMKCEE.
    > I think this is much simpler :-).
    >
    > Rather than change the standard report try to prepared your own that will be more
    > comfortable since it will be complex task to achieve editing the standard program.
    > Good Luck
    >
    > Regards
    > VEnk@
    >
    > Edited by: Venkat Reddy on Dec 11, 2009 4:52 PM
    Venkat,your answer is much simpler If the OP knows there is a tcode Se93, what if he/she does not know it?? 
    P.S: Just a thought.
    Regards.
    Vishwa.

  • I can´t rent movies on Apple TV I keep getting this message: Verification Required Before you can make purchases, you must go to the ITunes Store on your Computer and verify your payment information.

    I can´t rent movies on Apple TV I keep getting this message: Verification Required Before you can make purchases, you must go to the ITunes Store on your Computer and verify your payment information ? Done and still aren´t able to rent.

    Hi.
    You will need an iTunes acount !! then just log in to it and confirm your card payment details.
    I've don the same think!! good luck!  it works for me.

Maybe you are looking for