Results 1 to 6 of 6
  1. #1
    Resurgam is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Need Help with assignment

    My professor gave out an assignment but I have no idea where to start. I don't really get the instructions can anyone help?


    "Write a program that consists of one class called CSc2310. The constructor should take an int as a parameter and store it in a private instance variable called numRepetitions with public getters and setters. When the main method is run, it should construct an instance of this class, passing it a value of 100. You should then call execute() on the instance of the CSc2310 class you created.
    The execute() method should loop numRepetitions times. The loop should print the numbers 1 up to numRepititions each of their own line. However, if the loop is a multiple of 3, it should print CSc instead of the number. If the loop is a multiple of 5, it should print 2310 instead of the number. If the loop is a multiple of 3 and 5, it should print CSc 2310 instead of the number."

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need Help with assignment

    You need to understand Java basics to understand the instructions, and so I suggest that you start here: Really Big Index, and in particular this tutorial: Java Basics

    If you're still stuck after hitting the tutorials, please feel free to come back, but please try to ask more specific questions as they will usually get more specific answers.

    Best of luck.

  3. #3
    Resurgam is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Re: Need Help with assignment

    I'm sorry, but can you explain to me what the program is suppose to do? The assignment is due soon so I won't have time to finish the tutorials before that. My main issue with this assignment is that I don't know what this program is suppose to accomplish or am I suppose to find out after writing the program out?
    This is what I have at the moment, but I don't know how to implement the "execute()" method and what I am suppose to loop.


    public class CSc2310 {
    private int numRepetitions;

    public CSc2310(int initialNumber){
    numRepetitions = initialNumber;
    }
    public void setNumber(int initialNumber){
    numRepetitions = initialNumber;
    }
    public int getNumber(){
    return numRepetitions;
    }

    public static void main(String[] args) {
    CSc2310 tunaObject = new CSc2310(100);



    }

    }

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need Help with assignment

    Quote Originally Posted by Resurgam View Post
    I'm sorry, but can you explain to me what the program is suppose to do?
    I'm not sure how to answer this as the instructions seem pretty clear -- print the numbers unless a multiple of 3 or 5, ...

    Again, what specifically is confusing to you? As I noted previously, without a specific question, there's not much help we can offer here.

    The assignment is due soon so I won't have time to finish the tutorials before that.
    This is more your issue, not ours, but if you don't understand the basics, you'll find yourself facing a lot of frustration.


    My main issue with this assignment is that I don't know what this program is suppose to accomplish or am I suppose to find out after writing the program out?
    Again, you're not asking a specific question. WHAT confuses you. If the instructions aren't clear to you, have you contacted your instructor?

    This is what I have at the moment, but I don't know how to implement the "execute()" method and what I am suppose to loop.


    public class CSc2310 {
    private int numRepetitions;

    public CSc2310(int initialNumber){
    numRepetitions = initialNumber;
    }
    public void setNumber(int initialNumber){
    numRepetitions = initialNumber;
    }
    public int getNumber(){
    return numRepetitions;
    }

    public static void main(String[] args) {
    CSc2310 tunaObject = new CSc2310(100);



    }

    }
    Take the instructions and do one small step at a time. First print out each number on a line, test it make sure it works.
    Next try to implement the multiple of 3 part, test it make sure it works.
    Next try to implement the multiple of 5 part, test it make sure it works.

  5. #5
    Resurgam is offline Member
    Join Date
    Feb 2012
    Posts
    3
    Rep Power
    0

    Default Re: Need Help with assignment

    I apologize that my questions are not specific enough. But can you tell me what the output of this program is suppose to be?

    print the numbers unless a multiple of 3 or 5, ...
    What numbers do you refer to?
    am I suppose to print all numbers up to 100 except multiples of 3 and 5?

    It is really hard to contact my professor outside of class and he has not responded to any of my emails, which is why I am here.

    Any response would be appreciated

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need Help with assignment

    I think that your output would look something like:

    1
    2
    Csc
    4
    2310
    Csc
    7
    8
    Csc
    2310
    11
    Csc
    13
    14
    Csc2310
    16
    17
    Csc
    19
    2310
    et cetera on up to 100

    Every third String output would be Csc, every 5th 2310. Some numbers will be multiples of 15 (3*5) and will likely have both.

Similar Threads

  1. assignment help :L
    By Mike09lfc in forum New To Java
    Replies: 2
    Last Post: 12-03-2011, 03:38 AM
  2. Help With Assignment
    By EpyonCustom in forum New To Java
    Replies: 10
    Last Post: 04-03-2011, 07:04 AM
  3. Assignment
    By shinkymar in forum New To Java
    Replies: 2
    Last Post: 03-06-2010, 02:17 PM
  4. I am looking for help with an assignment
    By nanoo51969 in forum New To Java
    Replies: 1
    Last Post: 03-23-2009, 10:41 PM

Posting Permissions

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