Results 1 to 4 of 4
Thread: A simple parameter
- 02-07-2013, 06:36 PM #1
Member
- Join Date
- Feb 2013
- Posts
- 5
- Rep Power
- 0
A simple parameter
Hello,
I am just looking for a little bit of help with one of my homework assignments. I am hung-up on how to create a parameter that will make a printlin statement repeat itself. I have to make a the neck of the robot, shown below, two lines tall by using a parameter and setting it to two. I am not exactly sure how to accomplish this with just a parameter. I have only been able to make the neck one line tall.
Neck: | |
What I have now:
public class DoubleSum {
// Program for the above Robot 1. Changing the parameters
// will result in similar but different robots. Longer or shorter
// neck, body and legs. Wider body.
public static void main(String[] args) {
head();
neck(2);}
public static void head(){
System.out.println(".-------.");
System.out.println("| o o |");
System.out.println("| < |");
System.out.println("| --- |");
System.out.println("'-------'");
}
public static void neck(Object height){
System.out.println(" | | ");
}
}
To see the problem you can go to the link below.
Program 3, COS 160
Hope someone out there can help me! Thanks in advance!
~Steve
- 02-07-2013, 06:45 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 28
- 02-07-2013, 06:49 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 59
- Rep Power
- 0
Re: A simple parameter
Java Code:public class DoubleSum { // Program for the above Robot 1. Changing the parameters // will result in similar but different robots. Longer or shorter // neck, body and legs. Wider body. public static void main(String[] args) { head(); neck(2);} public static void head(){ System.out.println(".-------."); System.out.println("| o o |"); System.out.println("| < |"); System.out.println("| --- |"); System.out.println("'-------'"); } public static void neck(Object height){ System.out.println(" | | "); } }
also use the code brackets, and indent please
here is a good tutorial for loops
also when you have a method, you need to declare the pass type at the method
Java Code:public static void main (String[]args) { int value= 42; fattyBoomBoom(value); } public static void fattyBoomBoom(int value) { System.out.println(value); }
- 02-13-2013, 02:21 AM #4
Member
- Join Date
- Feb 2013
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Parameter help/question
By CuppaCoffee in forum New To JavaReplies: 6Last Post: 01-07-2012, 04:36 PM -
Output parameter
By xdzgor in forum JDBCReplies: 4Last Post: 11-19-2010, 09:03 AM -
how to pass parameter from one jsp to another jsp
By kader_sit in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 06-10-2010, 03:04 PM -
passing a parameter
By aarthi2learn in forum AWT / SwingReplies: 4Last Post: 12-22-2008, 06:46 AM -
Can a method take itself as parameter?
By bukake in forum New To JavaReplies: 10Last Post: 09-06-2008, 10:26 PM
Bookmarks