954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Array list or character ? in java

I want to create a a program in which i enter a word and the program counts the number of alphabets used in the word and display as output !!
I know its simple but i am just a beginner and my teacher wants to submit this as assignment


this is the question
2. A man wanted to enter a club but did not know the password that was required. He waited by the door and listend, a club member knocked on the door, the door man said "twelve" member replied "6" and was let in. Second member came to the door, doorman said "six" the member replied "3" and was let in. now the man throught that he had heard enough and walked up to the door, doorman said "eight" the man replied "4" but he was not let in. What should he say? so that he gets in.

ayaz.ali
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

and your problem being...?

freelancelote
Junior Poster in Training
89 posts since Aug 2008
Reputation Points: 34
Solved Threads: 2
 

i have no clue how to do it ??
i only started working a week ago i just know how to introduce integer and if and else and print hello world :p

ayaz.ali
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 
the program counts the number of alphabets used in the word and display as output !!

I'm guessing that by "the number of alphabets" you mean the number of letters your word has. If I'm guessing wright then use length() method of the String class.
Hava a look at the String class and at the trails .

2. A man wanted to enter a club but did not know the password that was required. He waited by the door and listend, a club member knocked on the door, the door man said "twelve" member replied "6" and was let in. Second member came to the door, doorman said "six" the member replied "3" and was let in. now the man throught that he had heard enough and walked up to the door, doorman said "eight" the man replied "4" but he was not let in. What should he say? so that he gets in.

What do you mean by that? Is it some kind of joke I didn't get?

freelancelote
Junior Poster in Training
89 posts since Aug 2008
Reputation Points: 34
Solved Threads: 2
 
What do you mean by that? Is it some kind of joke I didn't get?


That is the example for his problem.

jasimp
Senior Poster
3,623 posts since Aug 2007
Reputation Points: 533
Solved Threads: 53
 
That is the example for his problem.


ah!, it was too late in the morning!

freelancelote
Junior Poster in Training
89 posts since Aug 2008
Reputation Points: 34
Solved Threads: 2
 

he should say 5, by the way.

firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 
he should say 5, by the way.


ah! right! now I see why I never got into a club!

freelancelote
Junior Poster in Training
89 posts since Aug 2008
Reputation Points: 34
Solved Threads: 2
 

this is the answer about the count:

int counter (string s){
count=0;
for (int i=1;int i

rouhaifa
Newbie Poster
1 post since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

this is the answer about the count:

int counter (string s){ count=0; for (int i=1;int i Um, no... just no.

Ezzaral
Posting Genius
Moderator
15,986 posts since May 2007
Reputation Points: 3,250
Solved Threads: 847
 

this is the answer about the count:

int counter (string s){ count=0; for (int i=1;int i

No offense but this was worthless.How about using the s.length(). It already is a function that returns the number of character. And your counter has bugs.

firstPerson
Senior Poster
3,923 posts since Dec 2008
Reputation Points: 841
Solved Threads: 608
 

there is another way to solve this one i got it and told my teacher also made the program from it at last minute

12+6=18 which is divisble by 9 %=0
6+3=9 same %=0
so the answer will be 8+1=9 %=0

import java.util.Scanner;

class Guard
{	
	public static void main(String args[])
	{
	 int a;
	 int b;
	 int c;
	 int rm;
	
	Scanner input=new Scanner (System.in);
		System.out.print("Enter the digit that the guard has given you:");
	a=input.nextInt();
		System.out.print("Please enter your password:");
	b=input.nextInt();
	
	
	c = a + b;
	rm = c%9;
	

	if (rm==0 && b<9)
	System.out.println("Access granted ");
	
	else
	System.out.println("Wrong Password! Access denied");

	}
}
ayaz.ali
Newbie Poster
3 posts since Sep 2009
Reputation Points: 10
Solved Threads: 0
 

write a problem that determines the GCD of pairs of positive integers. the program shall repeatedly request for integer pairs and determine the GCD until one of the inputs received is less than 1.

aymahh
Newbie Poster
1 post since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

I want to create a a program in which i enter a word and the program counts the number of alphabets used in the word and display as output !! I know its simple but i am just a beginner and my teacher wants to submit this as assignment

this is the question 2. A man wanted to enter a club but did not know the password that was required. He waited by the door and listend, a club member knocked on the door, the door man said "twelve" member replied "6" and was let in. Second member came to the door, doorman said "six" the member replied "3" and was let in. now the man throught that he had heard enough and walked up to the door, doorman said "eight" the man replied "4" but he was not let in. What should he say? so that he gets in.

ans is [5] as word 'eight' contains 5 letters in it (as you can see in above eg. given............as in 'twelve' it contain 6 letters as in 'six' it contains 3 letter s

surbhi bhasker
Newbie Poster
2 posts since Oct 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: