Home
Forum
Software
Mouser's Software
NANY: New Apps for the New Year
Friends of DC
Forum Coding Snacks
Editorials
Daily Blog
Monthly Newsletter
Mini Reviews
Favorite Websites
Archives
Articles
Historical Archives
Testimonials: What Folks Say About Us
Licensing
Get a License Key
Commercial Licensing
Help
Search
FAQs
DonationCoder Sitemap
Live Chat (Discord)
Contact Us
About Us
Donate
Home
Forum
Software
Mouser's Software
NANY: New Apps for the New Year
Friends of DC
Forum Coding Snacks
Editorials
Daily Blog
Monthly Newsletter
Mini Reviews
Favorite Websites
Archives
Articles
Historical Archives
Testimonials: What Folks Say About Us
Licensing
Get a License Key
Commercial Licensing
Help
Search
FAQs
DonationCoder Sitemap
Live Chat (Discord)
Contact Us
About Us
Donate
This topic
This board
Entire forum
Website and forum (google)
Member search
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
6 Months
Forever
Login with username, password and session length
Saturday December 14, 2024, 5:22 pm
Proudly celebrating 15+ years online.
Donate now
to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
Forum Home
Search
Login
Register
Recent Topics
Go To..
Recently updated topics
Recent posts (compact)
Recent posts (full text)
DonationCoder.com Forum
»
Main Area and Open Discussion
»
General Software Discussion
»
java help
« previous
next »
New Topic
Print
Pages: [
1
] •
bottom
Author
Topic: java help (Read 3343 times)
jabborwoc
Participant
Joined in 2011
Posts:
5
java help
«
on:
April 03, 2011, 03:33 PM »
Java help open user spec file , count user spec character,
Code: Java
[Select]
import
java.util.Scanner
;
import
java.io.*
;
public
class
progChal6
{
public
static
void
main
(
String
[
]
args
)
throws
IOException
{
//needed for scanner class
Scanner kb
=
new
Scanner
(
System
.
in
)
;
String
filename
;
// file name
int
charCount
=
0
;
// get users filename
System
.
out
.
print
(
"Enter the file name: "
)
;
filename
=
kb.
nextLine
(
)
;
Scanner inputFile
=
new
Scanner
(
filename
)
;
// get users character
System
.
out
.
print
(
"Please enter a character: "
)
;
char
userChar
=
kb.
nextLine
(
)
.
charAt
(
0
)
;
// tell the user what the program does
System
.
out
.
println
(
"
\n
****This program will return how many times"
+
" the character you entered showed up in"
+
" the string you entered.****"
)
;
while
(
inputFile.
hasNext
(
)
)
;
{
(
filename.
charAt
(
)
==
userChar
)
;
{
charCount
++;
}
}
System
.
out
.
println
(
"
\n
The specified character "
+
"
\"
"
+
userChar
+
"
\"
is inside the string "
+
filename
+
" "
+
charCount
+
" times.
\n
"
)
;
inputFile.
close
(
)
;
}
}
«
Last Edit: April 03, 2011, 04:55 PM by mouser, Reason: formatted code
»
jabborwoc
Participant
Joined in 2011
Posts:
5
Re: java help
«
Reply #1 on:
April 03, 2011, 04:34 PM »
it just needs to count the number of times a specified letter occurs in a specified file
Ath
Supporting Member
Joined in 2006
Posts:
3,629
Re: java help
«
Reply #2 on:
April 04, 2011, 01:23 AM »
What's the result you are getting now?
If you added an
if
before the first bracket on line 27 there would at least be a comparison in the loop.
mouser
First Author
Administrator
Joined in 2005
Posts:
40,914
Re: java help
«
Reply #3 on:
April 04, 2011, 06:24 AM »
i think he got it solved in irc.
hamradio
Charter Honorary Member
Joined in 2006
Posts:
884
Amateur Radio Guy
Re: java help
«
Reply #4 on:
April 04, 2011, 01:12 PM »
The following url helped him if I remember correctly...
http://www.dreaminco...isplays-wrong-count/
Carroll -
HamRadioUSA.net
/
hamradio's Software Works
New Topic
Print
Pages: [
1
] •
top
« previous
next »
DonationCoder.com Forum
»
Main Area and Open Discussion
»
General Software Discussion
»
java help