Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2007, 03:47 AM
Member
 
Join Date: Jul 2007
Posts: 40
lenny is on a distinguished road
Help with, String, Char
Hi, i am writing a program for my class and is what it has to do is take a string input from the user and then it has to output the length of the string and how many vowels are in the string.
I have tried everything i can think of, but i need help. I keep getting unexpected type error on all of my if statements I think it is because of what I am trying to compare, but I just don't know any other way to do it. All i need is a little help or point me in the right direction.

Code:
import java.util.*; public class Assignment6 { public static void main(String[] args) { String a; int i, j, x; j = 0; x = 0; Scanner scannerKeyboard = new Scanner(System.in); System.out.println("Please enter a sentance: "); a = scannerKeyboard.nextLine(); a.toUpperCase(); for (i = 0; i <= 100; i++){ if (a.charAt(i) = (char)65) j++; else if (a.charAt(i) = (char)69) j++; else if (a.charAt(i) = (char)73) j++; else if (a.charAt(i) = (char)79) j++; else if (a.charAt(i) = (char)85) j++; else x++; } System.out.println("The length of the string entered is " + a.length()); System.out.println("The string you entered has this amount of vowels: " + j); System.out.println("It also has this amount of whitespace and consanants: " + x); } }
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-25-2007, 04:58 PM
Member
 
Join Date: Jul 2007
Posts: 8
mirage_87 is on a distinguished road
why are using "=" in a condition statement............u must be using "=="....
i guess this might solve yr problem.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Casting an int value into a char kurtulas New To Java 2 02-16-2008 10:03 PM
Cannot convert from char to String error sondratheloser New To Java 1 12-13-2007 11:28 PM
need help print char and digital lowpro New To Java 4 12-04-2007 09:20 AM
Char to String in java trill New To Java 1 08-01-2007 03:42 PM
How can i insert a char into a string Jamie New To Java 2 05-20-2007 11:01 PM


All times are GMT +3. The time now is 11:16 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org