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."

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.

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);

}

}

Re: Need Help with assignment

Quote:

Originally Posted by

**Resurgam** 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.

Quote:

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.

Quote:

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?

Quote:

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.

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?

Quote:

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

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.