Results 1 to 9 of 9
- 11-21-2012, 05:30 PM #1
Member
- Join Date
- Nov 2012
- Posts
- 9
- Rep Power
- 0
letters are in ascending order or not in ascending order.
Hello
I am currently learning about OO programming with java i am starting to get the grasp of it to some extent and i am finding it enjoyable.
One of the exercises i have been set by my lecturer, here is the brief:-
Read in a word and display if the letters are in ascending order or not in ascending order. Ignore letter case in your comparison.
I have an idea how to achieve this it is just implementing it that im not sure about.
Any help would be appreciated
Thanks
Josh
- 11-21-2012, 05:54 PM #2
Re: letters are in ascending order or not in ascending order.
What have you tried? Where are you stuck? Which part of this is giving you trouble?
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 11-21-2012, 11:14 PM #3
Member
- Join Date
- Nov 2012
- Posts
- 9
- Rep Power
- 0
Re: letters are in ascending order or not in ascending order.
Well i have had the thought that i need to get the program to look at each letter in the string and compare it to the lasst to see see if it is >= to the last. and if this is true for all of the letters then it will return true and false if not. Here is what i have done so far it is just my thoughts really i have not yet come across away to implement how i think the problem should be solved.
public class Main
{
public static void main (String args[])
{
System.out.print("#Enter phrase\n");
String P=BIO.getString();
while (! P.equals("END"))
{
/**
if (R.equals("TRUE"))
{
System.out.printf("%s letters in ascending order\n",P);
}
else if (R.equals("FALSE"))
{
System.out.printf("%s letters not in ascending order\n",P);
}
**/
System.out.print("#Enter phrase\n");
P=BIO.getString();
for (int x=0; x<P.length; x=x+1)
{
}
}
}
}
Thanks
also is there an area of this site where i can upload code and get some feedback on it.
- 11-22-2012, 12:23 AM #4
- 11-22-2012, 03:49 PM #5
Member
- Join Date
- Nov 2012
- Posts
- 9
- Rep Power
- 0
Re: letters are in ascending order or not in ascending order.
i have this so far it is an adaptation to a program that i wrote to count vowels in a phrase.
Java Code:public class Main { public static void main (String args[]) { String R="a"; System.out.print("#Enter phrase\n"); String P=BIO.getString(); while (! P.equals("END")) { if (R.equals("TRUE")) { System.out.printf("%s letters in ascending order\n",P); } else if (R.equals("FALSE")) { System.out.printf("%s letters not in ascending order\n",P); } System.out.print("#Enter phrase\n"); P=BIO.getString(); for (int x=0; x<P.length(); x=x+1) { if (P.charAt(x)>=x) { R="TRUE"; } else if (P.charAt(x)<x) { R="FALSE"; } } } } }
- 11-23-2012, 03:04 AM #6
- 11-23-2012, 02:52 PM #7
Member
- Join Date
- Nov 2012
- Posts
- 9
- Rep Power
- 0
- 11-23-2012, 04:21 PM #8
- 11-23-2012, 04:39 PM #9
Member
- Join Date
- Nov 2012
- Posts
- 9
- Rep Power
- 0
Similar Threads
-
search array - ascending order
By wiola111 in forum New To JavaReplies: 5Last Post: 08-28-2012, 03:09 PM -
Sorting in ascending and descending order
By flpanthers1 in forum New To JavaReplies: 10Last Post: 06-27-2011, 03:48 PM -
ascending order using array rush
By jca in forum New To JavaReplies: 2Last Post: 01-03-2011, 04:24 AM -
Checking ascending order of array
By counterfox in forum New To JavaReplies: 3Last Post: 10-22-2010, 10:44 PM -
How to add coins in ascending order in arraylist
By tribujohn in forum New To JavaReplies: 2Last Post: 01-23-2009, 04:31 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks