MikeB

Greenhorn
+ Follow
since Dec 11, 1999
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 MikeB

Hey Jim, Thanks.
I'll look at the code tommorrow. That's what I wanted was
to see some code that would do the job and then try to
learn from that. I'm so new to Java that I don't understand
most explanations given to me but at least with code I can look
at it, compile it, play around with it. Thanks for continuing
my education.
Mike B.
24 years ago
Thanks. I'm starting to get it very
sloooooooooooowly. Java is my first attempt to learn a programming language since 1979 when I learned COBOL, RPG II, and IBM Basic Assembler at Maxwell Institute in Norristown,
PA. This is oh so much different.
How would you change the code to do what you say needs to be done?
Thanks again,
Mike B.
24 years ago
Thanks Sheriff Wheaton for replying. I don't understand your answer but will study it and check the link you posted. What I understand is somehow when I type in 1 it becomes something other than what I wanted it to be.
24 years ago
Hi All,
I'm just learning Java and have written this simple program and need help in understanding while the output for the numbers in the range that should print out retiree,child, and teenager all print out, "You are an adult." I understand why when I type in symbols or letters I get, "You
are a retiree."
Thanks for your help.
Here's the code:
import java.io.*;
public class Mike {
public static void main(String[] args) {
System.out.println("Type your age here ");
int a = 0;
try {
a = (int)System.in.read(); }
catch(IOException e) {
System.out.println(a + "\t"); }
if (a < 13)
System.out.println ("You are a child.");
else if (a < 18)
System.out.println("You are a teenager.");
else if (a < 65)
System.out.println("You are an adult.");
else
System.out.println("You are a retiree.");
}
}
Mike B.
24 years ago
Thanks Mr. Saravanan for your help. After adding your code and adding import java.io.*;
as the first line of code, and then changing
char a to char a = 0, the program compiled.
Thanks again,
Mike B.
24 years ago
I failed to say that the pointer is under the parenthesis after the word read, not the ones around char.
Thanks.
24 years ago
Hi All,
I'm trying to learn Java through a couple of books and I need help. I haven't been able to compile a program that I copied exactly as written from the book. Here's the code:
public class Reply {
public static void main(String[] args) {
char a;
System.out.println("Enter a number from 1-3:");
a = (char)System.in.read();
switch(a) {
case '1':
System.out.println("\nYou win a car!");
break;
case '2':
System.out.println("\nYou picked the goat");
break;
case '3':
System.out.println("\nYou get to keep your 100");
break;
default:
System.out.println("\nIncorrect entry");
}


}
}
The problem is in the line of code:
a = (char)System.in.read();
The compiler puts a pointer under the parenthesis and says:7:Exception java.io.
IOException must be caught, or it must be declared in the throws clause of this method.
Would someone help me?
Thanks in advance.
Mike B.
24 years ago
Thanks everyone. I realized I better ask less
questions and do more reading since I'm such a beginner that I didn't even understand
"path". Luckily, between your posts and the great tutorial available on-line from Sun I'm
now compiling. In the book "Learn Java in 21
Days" they say upfront that it's written for
people with object-oriented programming experience- which I don't have. The tutorial has 8 pages devoted to getting one's first Java app to compile.
Thanks again,
Mike B.
24 years ago
Part of the previous post didn't print. I was asking, What do you mean when you say,"As long as your path is pointing toward JDK."
Thanks,
MikeB.
24 years ago
Thanks Paul for responding. I opened up the DOS prompt and typed in javac HelloWorld.java and got the bad command or filename message. What do you mean when you say <If you have your path pointing to your JDK>?
As far as using the JDK1.1.8- I just downloaded it from Sun's webpage. I must have missed the version you're referring to.
Thanks again,
Mike B.
24 years ago
I just got the book "Learn Java in 21 Days" from the library. I created a small program using Notepad and have not been successful in compiling it. I have win95. On the Taskbar I click START->RUN, then I type in: C:\jdk1.1.8\bin\javac C:\HelloWorld.java, and
nothing happens. A HelloWorld.class file isn't created. I'm obviously doing something wrong. Can someone help me?
Thanks in advance.
Mike B.
24 years ago