Array list or character ? in java

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2008
Posts: 1,471
Reputation: firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice firstPerson is just really nice 
Solved Threads: 190
firstPerson's Avatar
firstPerson firstPerson is offline Offline
Nearly a Posting Virtuoso

Re: Array list or character ? in java

 
0
  #11
Sep 18th, 2009
Originally Posted by rouhaifa View Post
this is the answer about the count:

int counter (string s){
count=0;
for (int i=1;int i<s.length();i++)
count ++;
return count;
}
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.
Last edited by firstPerson; Sep 18th, 2009 at 8:46 pm.
1) Prove that the area of a circle is pi*r^2, where "r" is the radius of the circle.
2) Problem 2[b]solved by : jonsca
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 3
Reputation: ayaz.ali is an unknown quantity at this point 
Solved Threads: 0
ayaz.ali ayaz.ali is offline Offline
Newbie Poster

Re: Array list or character ? in java

 
0
  #12
Sep 20th, 2009
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

  1. import java.util.Scanner;
  2.  
  3. class Guard
  4. {
  5. public static void main(String args[])
  6. {
  7. int a;
  8. int b;
  9. int c;
  10. int rm;
  11.  
  12. Scanner input=new Scanner (System.in);
  13. System.out.print("Enter the digit that the guard has given you:");
  14. a=input.nextInt();
  15. System.out.print("Please enter your password:");
  16. b=input.nextInt();
  17.  
  18.  
  19. c = a + b;
  20. rm = c%9;
  21.  
  22.  
  23. if (rm==0 && b<9)
  24. System.out.println("Access granted ");
  25.  
  26. else
  27. System.out.println("Wrong Password! Access denied");
  28.  
  29. }
  30. }
Last edited by ~s.o.s~; Sep 20th, 2009 at 10:17 am. Reason: Added code tags, please learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: aymahh is an unknown quantity at this point 
Solved Threads: 0
aymahh aymahh is offline Offline
Newbie Poster

greatest common divisor

 
-4
  #13
Oct 13th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 2
Reputation: surbhi bhasker is an unknown quantity at this point 
Solved Threads: 0
surbhi bhasker surbhi bhasker is offline Offline
Newbie Poster

reply

 
-1
  #14
Oct 25th, 2009
Originally Posted by ayaz.ali View Post
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
Reply With Quote Quick reply to this message  
Reply

Tags
array, character, java

Message:




Views: 1907 | Replies: 13
Thread Tools Search this Thread



Tag cloud for array, character, java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC