Zach Christian

Greenhorn
+ Follow
since Aug 23, 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
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Zach Christian

Winston Gutkowski wrote:

Zach Christian wrote:I have a Country class, so how would I pass my Scanner into that? Can you show me?


Sure:Hopefully you get the idea..,

Another tip: Class names should generally be singular. And if you absolutely must make it plural, then call it 'Countries'. You don't have to forget good spelling just because you're writing a program.

HIH

Winston



Thanks for the help. Now, if multiple countries are inputted, how do I create multiple objects, say, in a "for loop"? One to data for each country?
8 years ago


I have a Country class, so how would I pass my Scanner into that? Can you show me?
Also I need for loop to run till i = NumOfCountries to create an object for each Country class.
8 years ago
Okay so I need a for loop to send user input to the class variables, and create a new object for each iteration of the for loop based off the number of countries being compared.

How would you create those objects in a loop and pass those scanner inputs?
8 years ago

Carey Brown wrote:

Zach Christian wrote:

Carey Brown wrote:A simple, non-OO way, would be to create a second array to contain the medalCount.



how would I reference the 2 arrays? Say user inputs "Germany" as the country and 1,2,3 for the gold/silver/bronze medals. How would one tie Germany to the number of medals to do a comparison of the other countries?






I don't think a HashMap (per Knute) is appropriate because you'll have to output the countries in the order that they were entered in the event of a tie. An ArrayList would be a better choice.



I am still not getting what I need for this program. I just need the country and the olympic medals per country (I can do the math for the array) but am unsuccessful.

>
8 years ago

Carey Brown wrote:A simple, non-OO way, would be to create a second array to contain the medalCount.

A more OO way would be to create a Country class with fields name and medalCount and have an array of those.



how would I reference the 2 arrays? Say user inputs "Germany" as the country and 1,2,3 for the gold/silver/bronze medals. How would one tie Germany to the number of medals to do a comparison of the other countries?
8 years ago
I am attempting to write a program to forecast an Olympic winner based off the American/Canadian forecasting types.

The program needs to do the following:
Ask the user what scoring method they would like to use to score the Olympics (a character).
• Prompt the user for the number of countries competing in the current Olympics.
• Read in the country names and their medal count.
• Print out the name of the winning country.
• In case of a tie, print out the winning countries in input order.

So far I've got the user input and an array setup, but I am overthinking how to store the medals for each country

8 years ago

fred rosenberger wrote:What - EXACTLY - are you doing to get this error? What have you done?



I have [tried]running a java program I created in cmd. Directory of my source code: C:\Users\Me\Documents\Party.java

I am just typing javac Party.java then java -classpath.Party

here's the code:


10 years ago
I am attempting to execute a beginner's program and I get this error every time:

Could not create Java Virtual Machine
A fatal exception has occurred

What do I need to do to remedy this?

Thank you for your help.
10 years ago
Figured out the problem.

Using the %JAVA_HOME%\bin was not working so I created a new variable called "Path" and just put "JAVA_HOME\bin"..

javac now works.
10 years ago

Zach Christian wrote:

Keith Lynn wrote:I'm not sure which tool you're using, but do you mean in your setup where you have Value: , the Path there is defined as C:\Program Files\Java\jdk1.7.0_25\bin? If so, you have an extra /bin in your path.



Tool? I am just using the Windows System Properties > Environment Variables.



This may be my problem, but when I went to setup the variables, there was no "Path" or "PATH". I tried creating a new one as well.
10 years ago

Keith Lynn wrote:I'm not sure which tool you're using, but do you mean in your setup where you have Value: , the Path there is defined as C:\Program Files\Java\jdk1.7.0_25\bin? If so, you have an extra /bin in your path.



Tool? I am just using the Windows System Properties > Environment Variables.

10 years ago
I have been using the FAQ section with no avail.

What I was asking is what you answered: "Can the javac be run from any directory?". Now to just get my path set correctly. This is where the issue lies.
10 years ago
Hello, I am new here.

I need some help figuring out why 1) I can't run my code and 2) the javac does not work in CMD.

I set the PATH and variables, so I don't know what I missing, or doing wrong, or both. I would really like to start programming ASAP, but this issue is throwing a wrench into my progress.

Here is my Variable setup:
Name: PATHEXT
Value: %Path%\bin;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

I have also created another path called "Path" which contains the \bin\ location for javac.exe.
C:\Program Files\Java\jdk1.7.0_25\bin

These are all under System Variables

I am running Windows 7 64 bit.


Also, since I new to the Java language (I have experience with Python) I need to know specifics on the whole "javac" thing (which directory can it be run from in cmd, etc).

Thank you so much.
10 years ago