What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Newbie Java Question

Newbie Java Question
Author: Message:
albert
Veteran Member
*****

Avatar

Posts: 2247
Reputation: 42
– / Male / Flag
Joined: Feb 2005
O.P. Roll Eyes  Newbie Java Question
So I decided I'd give programming a shot.. I got stuck there.. lol..

The answer to my addition ( number 1 += number 2 ) gives me 22 when I enter 2 and 2.. anyways.. can anyone see what's wrong with this code? lol thanks :)


code:

//***********************************
//Program Information
//***********************************
//Date Created : 09-09-06
//***********************************
//Goal : Simple Addition
//***********************************

import javax.swing.JOptionPane;

public class Alby2 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        String number1 ;    // First Number To Add String
       
        String number2 ;    // Second Number To Add String
       
        String result ;        // Result String
       
        String show ;         // To Show Text String
       
        number1 = JOptionPane.showInputDialog ( "Enter Your First Number To Add") ;        // Reading Number 1
       
        number2 = JOptionPane.showInputDialog ( "Enter Your Second Number To Add" ) ;    // Reading Number 2
       
        result = number1 += number2 ;    // Adding Up Both Numbers
       
        show = "The Result Is " + result ;    // Text + Answer
       
        JOptionPane.showMessageDialog (null , show ) ;    // Show Text
       
    System.exit ( 0 ) ;        // End Program
       
    }

}


This post was edited on 02-09-2010 at 09:57 PM by albert.
09-10-2006 03:57 AM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Newbie Java Question - by albert on 09-10-2006 at 03:57 AM
RE: Newbie Java Question - by ShawnZ on 09-10-2006 at 04:03 AM
RE: Newbie Java Question - by albert on 09-10-2006 at 04:04 AM
RE: Newbie Java Question - by segosa on 09-10-2006 at 12:52 PM
RE: Newbie Java Question - by RaceProUK on 09-11-2006 at 11:34 PM
RE: Newbie Java Question - by albert on 09-12-2006 at 01:13 AM
RE: Newbie Java Question - by RaceProUK on 09-12-2006 at 03:02 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On