Results 1 to 4 of 4
Thread: CMPS280 hmwk help please
- 09-10-2010, 11:36 PM #1
Member
- Join Date
- Sep 2010
- Posts
- 4
- Rep Power
- 0
CMPS280 hmwk help please
I have some homework to do and I need some help. We use jgrasp to write our programs! Please let me know if you can help!!
It consists of 4 problems. They are as follows
1.)Make a class called HW0.java. In this class, write the following A method called print with an int parameter that prints the number to the screen using System.out
A main method that calls the print method for the number 10 and 100.
2.)Make a class called HW1.java. In this class, write the following:
A method called doubleArray that has an int array as an input parameter and returns an int array in which each element has been doubled. In the main method, call this doubleArray method with input {2,5,8}. Print out the values of the array returned by the method. (This should be 4, 10, 16.)
A method called max that has an int array as an input parameter and returns an int representing the largest value in the array. Test this method from the main method for the values {20,5,15,40}. Print the result.
3.) Make a class called EX1.java. In this class, write the following:
A method called getArea that has two double parameters called base and height. The method should return a double value that is the area of this triangle, which is 0.5 * base * height.
In the main method, print the results of the getArea method for base 6, height 9 and base 5, height 5.
4.) Make a class called Car.java. This class should have:
An instance variable called year that is an int.
An instance variable called name that is a String
A constructor with parameters y and n, corresponding to the year and name. The constructor should assign y and n to the year and name variables.
An instance method called print that prints the year and name of the Car using System.out.println.
A main method that constructs a car with year 2010 and name "Mustang", then prints the car's information using the print method.
- 09-11-2010, 12:08 AM #2
I shall simply answer your question with another question: Have you tried any of this yourself, or are you just hoping someone will do it for you?
If you answered yes to the latter, you're at the wrong forum (you'd want to look for a rent-a-coder instead). If you genuinely want to learn your course material (which I recommend), then try each of those four components first. If you should happen to come across issues, feel free to ask for some help solving them.
Just a quick note; if you need any help, make sure you've posted all the code in the project, any error message(s) you get (copied-and-pasted), and be specific in detailing the issue.
Good luck!
-
Agree with Zack as this is not the "do my homework for me" forum. My experience here is that if you show some effort you'll often get more help.
Luck.
- 09-11-2010, 12:51 AM #4
Senior Member
- Join Date
- Feb 2010
- Location
- Waterford, Ireland
- Posts
- 748
- Rep Power
- 4


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks