Results 1 to 6 of 6
Thread: Need Help with assignment
- 02-22-2012, 02:22 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
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.
- 02-22-2012, 06:32 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
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
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.
This is more your issue, not ours, but if you don't understand the basics, you'll find yourself facing a lot of frustration.The assignment is due soon so I won't have time to finish the tutorials before that.
Again, you're not asking a specific question. WHAT confuses you. If the instructions aren't clear to you, have you contacted your instructor?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?
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.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);
}
}
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.
- 02-22-2012, 08:18 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 3
- Rep Power
- 0
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?
What numbers do you refer to?print the numbers unless a multiple of 3 or 5, ...
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.
Similar Threads
-
assignment help :L
By Mike09lfc in forum New To JavaReplies: 2Last Post: 12-03-2011, 02:38 AM -
Help With Assignment
By EpyonCustom in forum New To JavaReplies: 10Last Post: 04-03-2011, 06:04 AM -
Assignment
By shinkymar in forum New To JavaReplies: 2Last Post: 03-06-2010, 01:17 PM -
I am looking for help with an assignment
By nanoo51969 in forum New To JavaReplies: 1Last Post: 03-23-2009, 09:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks