Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Problem-Area Of A Triangle

  • 24-05-2012 06:44PM
    #1
    Registered Users, Registered Users 2 Posts: 19


    I am new to java and learning. How do I write an application to calculate the area of a Triangle, where the area calculation is performed in a Triangle class not in the App class. Am at a loss with this one and what it means.
    Am using notepad++ .


Comments

  • Moderators, Politics Moderators, Paid Member Posts: 44,054 Mod ✭✭✭✭Seth Brundle


    College project?
    A quick google reveals loads of info on this.
    Maybe post your code so far.


  • Registered Users, Registered Users 2 Posts: 19 miguel2007


    kbannon wrote: »
    College project?
    A quick google reveals loads of info on this.
    Maybe post your code so far


  • Registered Users, Registered Users 2 Posts: 7,849 ✭✭✭Brussels Sprout


    If you're struggling with the maths have a look at this followed by this.


  • Registered Users, Registered Users 2 Posts: 19 miguel2007


    Not a college project. Learning Java and am struggling. Maths part I am okay with but differentiating between app class and triangle class and writing the correct code for this.


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Well first write the app with just an App class. Copy a "hello world" bog-standard program for this. Instead of printing hello world, calculate the area and print that instead.

    That's step 1. Do that before you try to do a Triangle class.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 455 ✭✭Ant


    miguel2007 wrote: »
    Not a college project.

    That's a coincidence. I had the exact same Java problem due for submission last Friday evening. :D

    I can't guess who you are from your Boards username but feel free to give me a shout as I wrote an intermediate command line version of the program which leaves out all the library code for the GUI windows so it's easier to see how the App() method interacts with the Triangle object.

    My Boards user name is simply the first 3 letters of my real name so now you know who I am.


  • Moderators, Politics Moderators, Paid Member Posts: 44,054 Mod ✭✭✭✭Seth Brundle


    If the OP is a student looking for an easy solution to a project then don't give them the source code. Let them learn how to do it! Otherwise, what's the point in a course exercise?


  • Registered Users, Registered Users 2 Posts: 9,153 ✭✭✭everdead.ie


    I'd recommend just get it working inside the Main method first and then once you have this working you can look at moving it to a seperate class.


Advertisement