operator cannot be applied to java.lang.string int

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Lucian Cyd
    New Member
    • Aug 2011
    • 1

    operator cannot be applied to java.lang.string int

    I dunno what to do. I get the following error:
    operator cannot be applied to java.lang.strin g int

    Code:
    public void actionPerformed(ActionEvent e)
    		{
    			
    
    		
    		if(e.getActionCommand().equals("Celsius"))
    		{
    		
    		
    		C = JOptionPane.showInputDialog("Enter temperature here: ");
    		
    		a1 =Double.parseDouble(C);
    			
    		Can = (C *9/5) + 32;
    			
    			JOptionPane.showMessageDialog(null, + Can + "Fahrenheit.");
    			
    		}
    Last edited by Niheel; Aug 13 '11, 11:22 PM.
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    C is a string and you are trying to multiply it with 9 and divide by 5. You can not perform arithmetic operations on Strings.

    I guess it should be
    Code:
    Can = (al *9/5) + 32;
    Regards
    Dheeraj Joshi

    Comment

    Working...