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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Please help with my JAVA ASSIGNMENT :(

  • 10-12-2013 12:10am
    #1
    Registered Users, Registered Users 2 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).


Comments

  • Registered Users, Registered Users 2 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,015 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 6,287 ✭✭✭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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    Still a teapot :pac:

    teapot.gif


  • Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    theedude27 wrote: »
    It's NCI actually:P

    Thanks for the clarification, will email them now.


  • Registered Users, Registered Users 2 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, Registered Users 2 Posts: 2,751 ✭✭✭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, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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,830 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, Registered Users 2 Posts: 40,038 ✭✭✭✭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, Registered Users 2 Posts: 40,038 ✭✭✭✭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, Registered Users 2 Posts: 2,751 ✭✭✭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, Registered Users 2 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, Registered Users 2 Posts: 40,038 ✭✭✭✭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?)


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    theedude27 wrote: »
    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!!!
    :) Lad, we're still waiting for that specific question the forum charter requires, and now you want to break the back-seat moderation rule as well? :)


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    ChRoMe wrote: »
    The vast majority of CRUD applications have little to no requirement for math.
    Yeah, and neither do the vast majority of data entry jobs. Do you really want to go to college for four years to learn to do something like that? Pick a shorter degree if you do, and prep for a fairly limited career unless you're angling straight for a managerial role and in that case, be more worried about your MBA than your degree (and please never work in a company I'm in, people who choose this path have almost invariably been far more work than they should be).


  • Closed Accounts Posts: 56 ✭✭theedude27


    Sparks wrote: »
    :) Lad, we're still waiting for that specific question the forum charter requires, and now you want to break the back-seat moderation rule as well? :)

    I might sound a bit out of order but I'm just getting frustrated at the fact that I have not gotten very far with the second part of my project and I'm getting all these replies to my thread (which has been merged with another thread) that don't relate directly to the question I asked (what keywords I should be using in the public class).

    Ugh I've been on boards.ie for a few years now but I rarely post anything and it's not easy to remember all forum rules so take it easy on this poor NooB lol


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


    Sparks wrote: »
    Yeah, and neither do the vast majority of data entry jobs. Do you really want to go to college for four years to learn to do something like that? Pick a shorter degree if you do, and prep for a fairly limited career unless you're angling straight for a managerial role and in that case, be more worried about your MBA than your degree (and please never work in a company I'm in, people who choose this path have almost invariably been far more work than they should be).

    I've been in IT over ten years, I think you are confusing me with one of the students. Billing over 300 a day writing Spring applications is not a bad way to make a living, its not particularly mentally taxing, however not having to work hard for ok money is a good thing in my book.


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    ChRoMe wrote: »
    I've been in IT over ten years, I think you are confusing me with one of the students. Billing over 300 a day writing Spring applications is not a bad way to make a living.
    Nope, it's good money (and that's nothing to sneeze at).
    I'd just go nuts in six months doing it :D

    (And yes, I know you're well out of college, I wasn't referring to "you" you, but "abstract" you. English sucks as a language for some things).


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,751 ✭✭✭MyPeopleDrankTheSoup


    Sparks, reading your response and after stalking your LinkedIn, it seems like you're in the 10% of cases where some maths might be important.

    Your average productive programmer coming out of comp sci is doing CRUD in some finance house and no maths is needed. It's also not as simple as a data entry job which I think is a bit insulting.

    I'm doing iOS/Android apps at the moment and there's no maths involved. I'm just joining APIs together. I just piggyback off the maths knowledge of the people in Google & Apple who are smarter and better programmers than me who wrote the libraries.


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


    George can you do the fizzbuzz test? Are you really saying that fizzbuzz is advanced maths that noone needs?

    Also this basic maths stuff is kinda handy in real life, do you get stumped by simple logic problems? Never cut any cloth? Or calculated the volume of something? Never encountered a triangle?

    There is a reason that this is compulsory in school.


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    theedude27 wrote: »
    I might sound a bit out of order but I'm just getting frustrated at the fact that I have not gotten very far with the second part of my project and I'm getting all these replies to my thread (which has been merged with another thread) that don't relate directly to the question I asked (what keywords I should be using in the public class).
    Generally, don't use any you don't need. Yeah, that sounds like a dumb answer, but what I mean is, the compiler has defaults for everything you create, and specifying keywords is how you override those defaults. For a college assignment where the actual math is the important part, stop worrying about whether a variable should be const or volatile or if a class should be static or not and just write the code. If you trigger a compiler warning or error, then go fix it, but don't waste an hour worrying over it at this stage.


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    after stalking your LinkedIn
    Ooooh, matron :D
    you're in the 10% of cases where some maths might be important
    Sometimes yes; but I've spent my time doing CRUD work as well, and even there it's damn important to do some math, even if only when provisioning (you expect 100 or more simultaneous users running a heavy server-side web-app at the same time and have a pretty nasty SLA - ie. one with serious financial penalties for unannounced downtime? you really need to do that math...). And the stuff I've done has gone from academic to industry, and from CRUD to new product design and to other wierd nooks as well, but none of that was planned (in other words, I couldn't tell you when I started what I wouldn't need to know - so I needed to know the math back then :) )
    I'm doing iOS/Android apps at the moment and there's no maths involved.
    There is, it's just hidden from you (and in some deep cases hidden from iOS).
    But you can't do anything that's going to have performance concerns without some level of math, even if it's more statisics than calculus (battery life? bandwidth usage? storage space? even those questions need math of some kind...)

    Well. You could ignore it, but you'd also have to ignore the bug reports ;)
    (Man, does that sound like a great idea on some days...)

    And no, not every job starts with firing up Wolfram, but I don't think I've done too many jobs over the years where you never needed any math at any point in the project. None that couldn't have been outsourced or offshored to Mumbai, anyway.


  • Closed Accounts Posts: 56 ✭✭theedude27


    Sparks wrote: »
    Generally, don't use any you don't need. Yeah, that sounds like a dumb answer, but what I mean is, the compiler has defaults for everything you create, and specifying keywords is how you override those defaults. For a college assignment where the actual math is the important part, stop worrying about whether a variable should be const or volatile or if a class should be static or not and just write the code. If you trigger a compiler warning or error, then go fix it, but don't waste an hour worrying over it at this stage.

    You are probably right Sparks but I just want the program to compile and not do the opposite of what the question specified it to do!! I am a weak programmer and some of the compiler error codes just confuse the hell out of me. Ok I'm done worrying and I'm just going to get back to it shortly and hope to get around 6 or 7 out of 10 for my efforts:rolleyes:


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


    Post the error and the offending line, we will help you. Oh, and start a new thread - this one is a mess :P As Sparks said, we will help with specific problems - but we will not do your assignment for you.


  • Closed Accounts Posts: 56 ✭✭theedude27


    srsly78 wrote: »
    Post the error and the offending line, we will help you. Oh, and start a new thread - this one is a mess :P As Sparks said, we will help with specific problems - but we will not do your assignment for you.

    Thanks and I would never expect anyone to do my assignments for me. Just a little push in the right direction is all I require:)


  • Registered Users, Registered Users 2 Posts: 240 ✭✭shleedance


    10 print "hello world"
    20 goto 10

    There's your solution.


Advertisement