Kyle Wettengel

Greenhorn
+ Follow
since Feb 06, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kyle Wettengel

I'm experimenting with arrays and while I can figure out how to enter the elements of a 2d-array based on user input I cannot figure out how to prompt the user to separately enter entire rows of the 2d-array (with a space in between each number) rather then entering each number then pressing enter. Could I get some help here? I know this will be on my next test, thanks guys!

Here's my code:

11 years ago
Ill follow you lead on this and make my class methods static, however in order to do this I will also have to make my instance variables static as well correct? When I do this everything looks like its working as it should except my min method, do you know why this is?

PS. I also changed the name to StatsDemo in my driver class thank you for pointing that out

New code

Main class:



Driver class:

11 years ago
The assignment also reads this for my demo class but i believe I've taken care of most of this already "Finally, create a StatsDemo class that creates a 20 element int array and populates it with random elements in the range 20 through 65 (both inclusive). The tester class should then test each of these methods. Use the java.util.Random class with a seed of 2621 to generate repeatable output for the data."
11 years ago
Thanks for the help guys, but my homework assignment (which is what this is for) says "Write a class Stats that has only class methods within it" thus I don't believe I'm allowed to use a constructor.....Is my logic correct?
11 years ago
Thanks for explaining it for me I believe I'm beginning to understand what needs to be done, first I renamed my classes so there easier to follow, second I created a new Array object in my driver class to attempt to pass the array to my Main class which is now renamed Stats, and lastly I attempted to set up my methods to take my array in my driver class as a parameter. Any hints as to what to do next? I would like to be able to print out the values of min, max, average, standard deviation at the end but I do not know how to write this, any hints or additional directions would be greatly appreciated!

New code:

Main class



Driver Class

11 years ago
Hey guys I'm having problems figuring out how to write my driver class for my Array class.

My questions

1.How do I make the array in my Array class reference the array in my Driver class?

2.How do I pass my class methods from my Array class to my Driver class so I can print them out?

Here's my two bits of code

Main class:



Driver class:

11 years ago
I dont have to print out the array, I just thought it would be a good way to check to see if its working properly
11 years ago
yes, right when there sorted I would like to print and store them so the sorted array can be used in my other class which calculates the mean median and mode.
11 years ago
If your talking about Arrays.sort() then yes I am! however I'm having trouble even with that, as of right now when I put the Arrays.sort(numbers); outside the for loop nothing changes when I outprint the array (the numbers are still printing out, they're just not sorted) This made me believe that I had to also move my System.out.println(numbers[i]) outside the for loop as well. However when I do this I get an error saying that it cannot find the variable [i]

Here's my code:

11 years ago
Hey guys looking for some help with my ArrayTester class...
The array is supposed to
1.create a 20 element int array and populates it with random elements in the range 20 through 65 (both inclusive).
-I Believe I have already done this.

2.Use the java.util.Random class with a seed of 2621 to generate repeatable output for the data.
-I have also already done this

3.The tester class should then test each of these methods(mean, median, mode, max, min, standard divination)
-this is where I'm having trouble, I already have the code for the mean, mode, max, min, and standard divination.. the problem I'm having is with the median as i would like to sort my array in the tester class before having it called by my main Class.

Is there any way to do this?

Here is my code:

11 years ago
Hey guys I'm having trouble figuring out how to calculate the standard divination of an array in Java. As you can see I have already calculated the mean, and I know that at the end I will have to divide by the sample size minus 1 (n-1) and square that number. The problem I'm having is how to take every number and calculate how far it is away from the mean, then square that number. I know I could do every number from the data set separately but there has to be an easier way. Any help would be appreciated, here's my code.

11 years ago
so rewriting the no arg constructor I would get




correct?
11 years ago
I did a little more digging and I changed a few things around including getting rid of the checkMoney methods, replacing the while statements, and changing around my toString, equals, and plus methods...Everything is compiling, let me know what you think.

11 years ago
I keep getting an error in my MoneyDemo class, it reads, "Method checkMoney in class Money cannot be applied to given types; required: no arguments; found int, int; reason:actual and formal argument lists differ in length"

Also here is my list of objectives for the program which I'll be graded on, If you notice any other errors in my code which I may run into later please feel free to point them out for me!

Use BlueJ to create a Money class with two integer instance variables, dollars and cents. Provide the following methods:

1. A two-parameter constructor that initializes the instance variables. The constructor should check that the cents value is between 0 and 99, and if not, transfer some of the cents to the dollars variable to make it between 0 and 99.
2. A default constructor that initializes the dollars to 0 and cents to 1. It should call the two-parameter constructor.
3. A one parameter constructor that initializes the cents value while setting the dollars value to 0. This constructor should also check that the cents value is between 0 and 99, and if not, transfer some of the cents to the dollars variable to make it between 0 and 99.
4. Accessors for dollars and cents
5. The standard toString method
6. The standard equals method that compares if two Money objects have the same state.
7. The plus method that takes a Money object as its parameter. It creates and returns a new Money object representing the sum of the object whose plus() method is being called and the parameter. It does NOT modify the values of the two existing objects.

Finally, create a MoneyDemo class that creates multiple Money objects. This demo class should test all constructors and methods that you have implemented.

Here is my code:

11 years ago