Collin Sampson

Greenhorn
+ Follow
since Feb 27, 2012
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
16
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Collin Sampson

Sure Paul.

The Program is Outputting:

11 years ago
Okay, I see.

It should've been: Array Output (No rush though) ;D

11 years ago
Why is for loop in the display method only printing the first argument (oneArray) correctly? It is only repeating the other arguments...

11 years ago
Okay I put in some test code and checked the highest and lowest values after each loop. It sets 15 to highest and lowest as it should but when I input 1 for the next value, it still has 15 as both the highest and lowest values. It is not executing the if statements within the loop for index = 1. I don't understand...
11 years ago
I have a problem in my beginning java class..

There are seven judges scores on each dive and a difficulty for the dive ranging from 1.2 to 3.8. To determine the final score, the lowest score and highest score are eliminated, then multiplied by the difficulty, then multiplied by .6.

(5 scores) * (difficulty) * .6 = final score

Here's my code, I can't tell why its not working. First time using an array.



It is compiling and running, but the calculations are wrong. I ran the scores...
15, 1, 10, 10, 10, 10, 10
And a difficulty... 1.5
Which should be (50) * (1.5) * .6 = final score of 45

Instead it returns... final score of 67.5 =(
11 years ago
So, I have an assignment in beginning java in which 3 guys (Aaron, Bob, Charlie)shoot at each other until 1 is left standing.
Stipulations:
Aaron shoots first and hits with 33% accuracy.
Bob shoots second and hits with 50% accuracy.
Charlie shoots last and hits every time.
Each shooter aims for the best shot (so Aaron and Bob would shoot at Charlie if he was still alive).

We have not yet studied inheritance and I'm a beginner so go easy on me.
Here is what I have. I have not yet included a main method and I've been working at this for too long...please help me out.

import java.util.*;



The last method is giving me an error, which I understand, but I don't see any other way to do it.
Should each shooter have his own class? How can I check to make sure at least two people are alive after each round?

11 years ago
Yes I do, I forgot the () on both so the compiler was not looking for the methods. Right? Thanks for the help
12 years ago
Okay I got that. Now I am trying to test the program but the tester I have created is not compiling. Here is the tester:



The error says that it cannot find either getDegreesC or getDegreesF.
Some help please.
12 years ago
Why do I keep receiving a complier message reading: unexpected types?? The error is occuring at the method setCharacter() (lines 37 and 41 specfically), it doesn't make sense to me. I am using a string method with a String variable (character). To determine if the program will convert to degreesC or degreesF. Where did I go wrong?

12 years ago
This is my first time using instance variables and the 'new' operator, so bear with me. I am trying to make a program that functions as an odometer, with a trip odometer and total odometer. I have included a method that resets the trip odometer before each trip. There are three different trips, but within each trip there are smaller trips that accumulate on the trip odometer. The user inputs mpg and miles driven on each trip. It then ouputs their mpg, trip odometer, total odometer, and gallons of gasoline used since last reset (for each trip).

I am having a problem with the total odometer. I need it to add each trip odometer for a grand total but it is only echoing the trip odometer.
Here's my code...

import java.util.*;



And the tester...


12 years ago
Thanks for the help. I both wrote it out and looked at the code provided. Makes sense now.


initialization = size -1
boolean expression = numStars >= 0
change = numStars-- (one less star on each line)
12 years ago
I am trying to make a program that prints a triangle made of asterisks with maximum length of user input:
So if the user inputs 5, it should look like this:
*
**
***
****
*****
****
***
**
*
I got my program to do the first loop, up until the maximum. I would appreciate some help on how to make it flip.
Is it a separate for-loop? Is it another, nested, for-loop?
Here is my code:

12 years ago
Now I see!
1. I stored the calculated height as a double
2. Changed the 13 to 13.0 to convert to double,
3. Type casted the height to an integer and did integer arithmetic to separate feet from inches.
4. Also declared inches as decimal format object and defined it as: height % 12.

12 years ago
How is the input not an integer though? I am asking for two whole numbers, feet first then inches. When I replace '12' with 12.0, I get an error: "loss of precision".

The output is wrong because if I input '10' then '0' for height of both parents it ouputs that the height of the male child will be 10 feet and 0 inches. The correct answer should be 10 feet and 5 inches roughly.

And I still don't understand why it is not allowing user input after asking: "Enter another gender to keep going or 'stop' to quit." It goes straight to the next question.

Output looks like this:

Enter another gender to keep going or 'stop' to quit.
Enter father's height, feet first then inches.
Seperate feet and inches by a space.
(Then allows user input)
12 years ago
I am making a program that estimates the height of a child based off gender, height of mother, height of father, and given equations. The program should allow the user to enter a new set of values and output predicted height until user decides to exit. Here is my code. When I run the program, first of all the calculations are coming out wrong and secondly, after the loop has ran, it skips the second gender/stop input line and goes straight to asking for height of father again.
I have attached a copy of my output.



Picture 1
12 years ago