944,208 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 4489
  • Java RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Sep 18th, 2009
0

Re: Array list or character ? in java

Click to Expand / Collapse  Quote originally posted by rouhaifa ...
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.
Reputation Points: 840
Solved Threads: 594
Senior Poster
firstPerson is offline Offline
3,865 posts
since Dec 2008
Sep 20th, 2009
0

Re: Array list or character ? in java

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

Java Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ayaz.ali is offline Offline
3 posts
since Sep 2009
Oct 13th, 2009
-4

greatest common divisor

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
aymahh is offline Offline
1 posts
since Oct 2009
Oct 25th, 2009
-1

reply

Click to Expand / Collapse  Quote originally posted by ayaz.ali ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
surbhi bhasker is offline Offline
2 posts
since Oct 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Urgent! I need to teach someone 'special'
Next Thread in Java Forum Timeline: JText





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC