Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    rectangle message box beginner lol

    im just a beginner, but what is the error in this?; how do i make 2 rectangle message box form?






    package inputboxes;
    import javax.swing.JOptionPane;

    public class InputBoxes {
    private static String family_number;
    private static String string_to_convert;


    public static void main(String[] args) {

    String first_number;
    first_number=JOptionPane.showInputDialog("First Number", "Enter Your First Number");

    String family_number;
    family_number=JOptionPane.showInputDialog("Family Number", "Enter You Family Number");

    String full_name;
    full_name= "Your number" + first_number + " " + family_number;

    String breadth;
    breadth=JOptionPane.showInputDialog("Rectangle Breadth");
    Integer.parseInt(first_number)

    String breadth;
    breadth=JOptionPane.showInputDialog("Rectangle Breadth");
    Integer.parseInt(family_number)

    int area=Integer.parseInt( string_one )*Integer.parseInt( string_two);

    JOptionPane.showMessageDialog( null, full_name);
    System.exit(0);

  • #2
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Before getting into that string-handling problem, there seems to be a bug in the routine you used to compare the title of this forum with the name of the subject you're studying.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Logic Ali is trying to tell you that this is the JavaSCRIPT forum. Your question is about JAVA.

    The two languages are about as similar as, say, English and Dutch. No, maybe not that similar.

    Anyway, the first bug you have is obvious:
    Code:
        String breadth;
        breadth=JOptionPane.showInputDialog("Rectangle Breadth");
        Integer.parseInt(first_number)
    
        String breadth;
        breadth=JOptionPane.showInputDialog("Rectangle Breadth");
        Integer.parseInt(family_number)
    You can't have two variables ("breadth") with the SAME NAME within the same scope.

    Happens to be true in JavaScript, as well, not that that is relevant to your JAVA problem.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New to the CF scene
    Join Date
    Aug 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    whats the difference between javascript and java lol.

    dont be rude to me =(

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Short answer:

    JavaScipt is, as the name implies, a *SCRIPTING* language. It is used primarily as *THE* scripting language of the Web, as a part of probably most HTML pages that are out there.
    It is an "untyped" language, meaning that variables do not have declared types. You can do stuff like this:
    Code:
        var a = 3.14159264; // hold a floating point number
        a = "change it to a string"; 
        a = new Date(); // change it to an object reference
        a = false; // and a boolean
        a = 17; // and an integer...though JavaScript really doesn't care if a number is integer or floating point
    JavaScript is able to interact directly with the HTML elements on your page. It can read or change the contents or the style of any element, for example. JavaScript normally has not server-side component.

    JavaScript files are typically located on a web server and then served up to browsers using the HTTP protocol exactly the same way HTML pages are. (Alternatively, you can actually embed JavaScript code directly in the middle of an HTML page.)

    ********************************

    Java, the language you are studying, is a COMPILED language. When it executes, it normally is compiled all they way down to the machine code of the CPU in use. It is a tightly typed language: You must declare all your variables to be a single data type, and you can't assign a value of a different type to a variable (but look up "cast" for ways to change types). Java normally runs on the server (when used in a Web environment) or it can execute standalone code (that is, code that runs on the same computer where the files are found...not sent from a server to a client).

    Java *can* be used in the web environment as APPLETS. Originally, when Java was first created, it was almost assumed that this would be the de facto use of Java. But applets turned out to be heavy-weight and clumsy compared to using JavaScript, and Java turned out to be a pretty darned good language for writing server-side code (as in the use of JSP--Java Server Pages) and so applets, while still around, are much much less prominent.

    *************

    The general syntax of the two languages does, at first glance, appear to be quite similar. In reality, the similarities are pretty much the same as you find between Java and C and C++ and C# and other related languages. Operators and variable usage look the same, but once you start getting into other coding, the difference are more profound than the similarities.

    *************

    There, that was the short version. For the long version, send $19.95 and two boxtops to ...
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    Quote Originally Posted by sniperkills90 View Post
    whats the difference between javascript and java lol.

    dont be rude to me =(
    LMGTFY

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    LMGTFY

    Hey! That's what I was going to charge him the $19.95 (and two boxtops) for!

    You trying to cut into my income?

    <grin/>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •