Help Community Login:




9 replies [Last post]
Evil Monkey's picture
Evil Monkey
Moderator (Watching Over The Masses)Premium Member (Silver)The Steel CurtainI use FirefoxI use Google ChromeI use Internet ExplorerI use SafariI'm Here To Help, & Have Proven It!Windows UserMember of VileThe JokerSomeone thinks you're a Rotten Tomato!STaRDoGG <3's you ;)
Joined: 01/22/2009
Posts: 226
Drops: 330

Hey Dog,

Learning a bit of java at the moment.

I wrote a small app that simply will take input from a user for the radius of a cirlce then spit out the Area, circumference, and diameter. Here is my code. But what I'd like to do is compile it as an exe or i'm thinking .jar file so I can simply run it in an OS environment. Can you point me in the right direction on how to do this. Doesn't seem my app "eclipse" can do this or at least I'm not seeing it. Here's my code.

<br />
/***********************************************************************<br />
  Program Name: Circle.java<br />
  Programmers Name: Glen Ciszewski<br />
  Program Description: This program will calculate the area, circumference and diameter of a circle<br />
  ***********************************************************************/<br />
import javax.swing.JOptionPane;<br />
public class Circle <br />
{<br />
<br />
   <br />
   public static void main(String[] args) <br />
   {<br />
      String userInput;      //number entered by user<br />
      int radius;            //converted input for number<br />
      double diameter;      //the diamater of the circle<br />
      double circumference;   //the circumference of the circle<br />
      double area;         //the area of the circle<br />
      <br />
      //read in the users input as string<br />
      userInput = JOptionPane.showInputDialog("Enter in the radius");<br />
      <br />
      //convert number from string to type int<br />
      radius = Integer.parseInt(userInput);<br />
      <br />
      //find the diameter<br />
      diameter = 2*radius;<br />
      <br />
      //display the diameter<br />
      JOptionPane.showMessageDialog(null,"The diameter is " + diameter,<br />
            "Results",<br />
            JOptionPane.PLAIN_MESSAGE);<br />
      <br />
      //find the circumference<br />
      circumference = 2*Math.PI*radius;<br />
      <br />
      //display the circumference<br />
      JOptionPane.showMessageDialog(null,"The circumference is " + circumference,<br />
            "Results",<br />
            JOptionPane.PLAIN_MESSAGE);<br />
      <br />
      //find the area<br />
      area = Math.PI*radius*radius;<br />
      <br />
      //display the area<br />
      JOptionPane.showMessageDialog(null,"The area is " + area,<br />
            "Results",<br />
            JOptionPane.PLAIN_MESSAGE);<br />
      System.exit(0);<br />
      <br />
    }<br />
<br />
}<br />

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <embed> <object> <strike> <caption> <thead> <th> <param> <style> <BGSOUND> <color> <center> <font-size> <script>
  • You may quote other posts using [quote] tags.
  • Filtered words will be replaced with the filtered version of the word.
  • Textual smileys will be replaced with graphical ones.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <csharp>, <css>, <html4strict>, <javascript>, <php>, <vb>, <vbnet>, <xml>. Beside the tag style "<foo>" it is also possible to use "[foo]".
  • Lines and paragraphs break automatically.
  • You can use BBCode tags in the text.

More information about formatting options



NOT LOGGED IN

You are NOT logged in

NOTE: You are commenting as an anonymous guest. You will NOT immediately see your comment, but it's there. Please do not try to re-send the same comment. If you'd like to see it immediately, please login or create an account (no worries, it's free).


facebook codes exploits tips tricks Phrozen Crew
All contents ©Copyright GeekDrop 2009-2012
TOS | Privacy Policy