Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Please help with my JAVA ASSIGNMENT :(

Options
  • 10-12-2013 1:10am
    #1
    Registered Users Posts: 46


    Hi All,

    Recently had a baby and have falen behind in java assignments. Any help with the following would be much appreciated;

    Given the functions

    f,g:Z→Z where
    f(x)= 3x+2 and
    g(x)= 〖8x〗^3 .

    Calculate the inverse of f(x) and the inverse of g(x).

    Write a program that will allow a user to enter a value for x and returns an output value for each of the compositions:

    f∘f
    g∘g
    f∘g
    g∘f
    f^(-1)∘f
    g^(-1)∘g


    Given the predicates

    P(x):x is odd and
    Q(y):y >5

    Write a Java program that will allow a user to enter values for x and y and return output values for the following:

    the conjunction of P(x) and Q(y)
    the disjunction of P(x) and Q(y)
    the negation of Q(y).


«1

Comments

  • Registered Users Posts: 341 ✭✭Mo14


    No one's going to do your assignment for you. Why not post your attempt so far, and tell us where you're having problems.


  • Closed Accounts Posts: 8,016 ✭✭✭CreepingDeath


    nate19841 wrote: »
    Recently had a baby and have falen behind in java assignments.

    Then I'm sure you can provide a doctors note to present to your lecturer to request an exemption or a bit more flexibility in time to hand up your assignments.


  • Registered Users Posts: 710 ✭✭✭mad turnip


    if you have a problem understanding the maths maybe its worth researching that first and doing it on paper and then writing the code.


  • Registered Users Posts: 6,016 ✭✭✭Talisman


    nate19841 wrote: »
    Calculate the inverse of f(x) and the inverse of g(x).
    There's a website that can do this for you : WolframAlpha


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


    Yes but it's really basic maths.... If you have to use wolfram as a crutch then maybe some basic algebra lessons are in order.

    This is covered at junior cert level right? http://www.purplemath.com/modules/invrsfcn3.htm

    When people say "oh you don't need maths to do computer science" they mean advanced maths. You do need basic algebra, as this assignment demonstrates.


  • Advertisement
  • Closed Accounts Posts: 445 ✭✭rwg


    wow - java has changed, my assignment was to make a kettle


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


    That's the standard assignment for computer graphics, and it's a teapot not a kettle :p

    TeapotLight.png


  • Closed Accounts Posts: 445 ✭✭rwg


    graphics me arse - this was command line :P


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


    Still a teapot :pac:

    teapot.gif


  • Registered Users Posts: 60 ✭✭mrnobodyfan87


    nate19841 wrote: »
    Hi All,

    Recently had a baby and have falen behind in java assignments. Any help with the following would be much appreciated;

    Given the functions

    f,g:Z→Z where
    f(x)= 3x+2 and
    g(x)= 〖8x〗^3 .

    Calculate the inverse of f(x) and the inverse of g(x).

    Write a program that will allow a user to enter a value for x and returns an output value for each of the compositions:

    f∘f
    g∘g
    f∘g
    g∘f
    f^(-1)∘f
    g^(-1)∘g


    Given the predicates

    P(x):x is odd and
    Q(y):y >5

    Write a Java program that will allow a user to enter values for x and y and return output values for the following:

    the conjunction of P(x) and Q(y)
    the disjunction of P(x) and Q(y)
    the negation of Q(y).

    What class is this for?


  • Advertisement
  • Registered Users Posts: 5 xandrey


    What class is this for?

    All NCI first year students (computing) following this thread :)


  • Closed Accounts Posts: 56 ✭✭theedude27


    Another person in my class already posted this up. I've solved the first problem but I'm only repeating maths this year and haven't touched Java in over 6 months so I'm quite rusty when it comes to If and Else statements.

    Can anyone give me some guidance as to which classes I would need to include for the predicates problem i.e. private int, boolean, double etc. Just really need to know how I should start the program so I can figure out the rest of it. I thought the functions question would be much harder but it doesnt seem so!!


    Given the functions

    f,g:Z→Z where
    f(x)= 3x+2 and
    g(x)= 〖8x〗^3 .

    Calculate the inverse of f(x) and the inverse of g(x).

    Write a program that will allow a user to enter a value for x and returns an output value for each of the compositions:

    f∘f
    g∘g
    f∘g
    g∘f
    f^(-1)∘f
    g^(-1)∘g


    Given the predicates

    P(x):x is odd and
    Q(y):y >5

    Write a Java program that will allow a user to enter values for x and y and return output values for the following:

    the conjunction of P(x) and Q(y)
    the disjunction of P(x) and Q(y)
    the negation of Q(y).


  • Closed Accounts Posts: 56 ✭✭theedude27


    Just thought I'd show what I used to solved the first problem:

    public class InverseFunction{
    private int x;
    private int y;

    public InverseFunction(){
    x = 0;
    y = 0;
    }


    I find doing the Logic stuff easier than doing the Relations & Functions on paper but when it comes to Java, well.......


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    Someone should send a link to this forum to the NUI computer science department.


  • Closed Accounts Posts: 56 ✭✭theedude27


    ChRoMe wrote: »
    Someone should send a link to this forum to the NUI computer science department.

    It's NCI actually:P


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    theedude27 wrote: »
    It's NCI actually:P

    Thanks for the clarification, will email them now.


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


    Some useful links (and not so useful pictures of teapots) on the other NCI thread: http://www.boards.ie/vbulletin/showthread.php?t=2057101320

    If you guys keep making threads for the same question things could get a bit cluttered.


  • Closed Accounts Posts: 56 ✭✭theedude27


    srsly78 wrote: »
    Some useful links (and not so useful pictures of teapots) on the other NCI thread: http://www.boards.ie/vbulletin/showthread.php?t=2057101320

    If you guys keep making threads for the same question things could get a bit cluttered.

    In the other thread, the guy didnt know where to start with the project in general. I've done the maths for my project and solved the first problem (which is an achievement in itself as I hate both maths and programming and don't rate myself in either of them) and all I'm seeking is a bit of guidance with the classes to use for the second problem!!


  • Registered Users Posts: 2,709 ✭✭✭MyPeopleDrankTheSoup


    srsly78 wrote: »
    When people say "oh you don't need maths to do computer science" they mean advanced maths. You do need basic algebra, as this assignment demonstrates.

    When was the last time you used any maths, basic or not, in production code?

    Your average, modern, productive coder is a plumber, joining APIs together. No need to know any maths in the vast majority of cases.


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


    Well you have to have the maths right before you even attempt to write any code. That inverse function you posted just has a contructor, the actual "machinery" of the function is not there so it does nothing.

    The second part of the exercise (which you have bolded) seems even easier than the first part.

    http://en.wikipedia.org/wiki/Logical_conjunction -> it's just a fancy way of saying AND.

    So write a function for P(X) which returns true if x is odd.
    Then write a functon for Q(y) which returns true if y is greater than 5.
    Then in your main body of code just return ( P(x) && Q(y) ). && is the code way of doing logical AND.

    Here is a basic reference on how to write classes: http://www.tutorialspoint.com/java/java_object_classes.htm

    Note that you do not have to write a class for every single bit of the problem, you can make a bigger class called NCIAssignment, and have the various functions you need as members.


  • Advertisement
  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    When was the last time you used any maths, basic or not, in production code?

    Your average, modern, productive coder is a plumber, joining APIs together. No need to know any maths in the vast majority of cases.

    Ain't that the truth!


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


    No. Things like logical AND OR etc are basic maths that everyone needs. Even api plumbers need to know about true and false!

    I use lots of maths, but you are right the work I do is not typical.


  • Technology & Internet Moderators Posts: 28,792 Mod ✭✭✭✭oscarBravo


    When was the last time you used any maths, basic or not, in production code?
    All. The. Time.


  • Closed Accounts Posts: 56 ✭✭theedude27


    srsly78 wrote: »
    Well you have to have the maths right before you even attempt to write any code. That inverse function you posted just has a contructor, the actual "machinery" of the function is not there so it does nothing.

    The second part of the exercise (which you have bolded) seems even easier than the first part.

    http://en.wikipedia.org/wiki/Logical_conjunction -> it's just a fancy way of saying AND.

    So write a function for P(X) which returns true if x is odd.
    Then write a functon for Q(y) which returns true if y is greater than 5.
    Then in your main body of code just return ( P(x) && Q(y) ). && is the code way of doing logical AND.

    Here is a basic reference on how to write classes: http://www.tutorialspoint.com/java/java_object_classes.htm

    Note that you do not have to write a class for every single bit of the problem, you can make a bigger class called NCIAssignment, and have the various functions you need as members.

    Thanks for your guidance Srsly78. I'll have a look through those links and see what I can come up with. Just to clarify I have done the "machinery" of the code and the program works fine. I just wasn't posting all of the code up here and letting others take my code and pass it off as their own work:mad:


  • Registered Users Posts: 40,055 ✭✭✭✭Sparks


    Merging the threads to keep things tidier.

    And you did read the forum charter before posting, right?
    Right?

    Specifically this bit?
    Evil Phil wrote: »
    RIGHT YOU 'ORRIBLE LOT!!!!

    If you are a learning to code in college, in your first job or just out of interest here are the rules for beginners when asking questions:
    • Try and give a good description of your problem in the thread title.
    • Post a sample of your code no matter how poor you may think it is. It shows an effort on your behalf and that's really important.
    • Try and explain your attempt in the previous point.
    • Now ask any questions you may have.
    • If there are any errror codes, messages, or a stack trace then post that too. I might look like gobbledegook to you but it contains everything you need to know to solve your problem.

    Follow these rules everywhere, here, on other forums, in work, in college and anywhere else you can ask a question. A willingness to learn to very important in development and nobody will fault you for asking a question as long as you've made a prior effort.

    You should also learn how to search the web. It's an acquired skill. If you repeatedly fail to come with a solution when searching well you should probably document your own efforts for the next person along, you young groundbreaker you!

    Follow the rules above and we'll get along fine. Repeat offenders will be banned. Anyone who laughs and points, sneers or generally gets sniffy at a poster following these rules will be banned for sure.

    All is well, consume.


    Postscript: Asking for an paid accomplice in plagarising coursework? Welcome to an instant ban from the forum. Seriously, cop the fsck on.


    Seriously, it's not a PFO - if you've got a specific question on something you don't grok, it's welcome here.

    But "tell me what to type in for this assignment" isn't a specific question, it's a request for plagarism and leaving aside how you've just made that request in public in a place your lecturers do know about, there's the point that most everyone here works in the software industry and half our lives are taken up fixing broken code written by people who should have studied harder, so we're not exactly unbiased.

    We love people trying to learn more and improve because they make our lives easier, and those trying to dodge work.... are not so high on our christmas lists. Something to keep in mind :)


  • Registered Users Posts: 40,055 ✭✭✭✭Sparks


    ChRoMe wrote: »
    Ain't that the truth!
    No, it's not. And half the time the people who don't learn the math make work for the rest of us. Take a read through any of the performance threads on HN or elsewhere and you'll find examples pretty fast, where people just didn't do a five-second back-of-the-envelope bit of math to see if their approach was feasible or not. You need to have both the math and the non-math stuff.


  • Registered Users Posts: 2,709 ✭✭✭MyPeopleDrankTheSoup


    Do you've any examples of code you've come across that made work for you because the original author didn't learn the maths? And not just crappy code, we all know about that, only instances where the lack of maths knowledge caused work for you. And if you're about to mention algorithms and Big O notation, you're outside the vast majority of cases. All IMO of course.

    Any links to some of these HN performance threads?


  • Registered Users Posts: 2,021 ✭✭✭ChRoMe


    Sparks wrote: »
    No, it's not. And half the time the people who don't learn the math make work for the rest of us. Take a read through any of the performance threads on HN or elsewhere and you'll find examples pretty fast, where people just didn't do a five-second back-of-the-envelope bit of math to see if their approach was feasible or not. You need to have both the math and the non-math stuff.

    The vast majority of CRUD applications have little to no requirement for math. Of course there are domains where its a requirement, however for the day to day CRUD operations of hitting a webservice, dealing with the database, whatever you are not explicitly doing calculations.

    Also please don't try to reference that absolute pit of rubbish that HN is to qualify a point.


  • Closed Accounts Posts: 56 ✭✭theedude27


    Eh lads, this is a post about a Java maths project that myself (to some extent) and another person happen to be struggling with. Can you please take your own argument about HN and "how much maths really goes into modern programming" to a separate thread please!!!


  • Advertisement
  • Registered Users Posts: 40,055 ✭✭✭✭Sparks


    Do you've any examples of code you've come across that made work for you because the original author didn't learn the maths?
    Short answer yes, longer answer NDA. :(
    I've personally worked on designs which simply couldn't meet the original design specs because nobody sat down and did the math on things like network response times. It's not always calculus, but it often involves statistics. For example, if your design works in the perfect network (zero latency, infinite bandwidth), does it also work with 3% packet loss? How about 7%? What if you have a 300km seperation between client and server? What's a reasonable average ping time in that case? And so on. (Sorry for not being more detailed, but I'm not joking about NDAs).

    To be honest, I usually find that bad math = crappy design, and bad API/language knowledge = crappy code... but a lot of crappy-looking code is actually crappy design being implemented as well as it could be, if you follow me.

    (Also, if you don't like HN, (a) have you tried HN/classic or HN/best and not clicking on the fight de powa threads?; (b) what about comp.risks, the ACM transactions or other sources?)


Advertisement