Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,739 members, 7,824,102 topics. Date: Friday, 10 May 2024 at 11:01 PM

Programmers In †ђє House Please Help Me Out - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Programmers In †ђє House Please Help Me Out (1306 Views)

10 Greatest Computer Programmers In History / No Programmers In Nairaland (2) (3) (4)

(1) (Reply) (Go Down)

Programmers In †ђє House Please Help Me Out by xteve(m): 11:30am On Jul 18, 2012
I would be grateful if the programmers in the house would help me out.
We were given an assignment in Java to arrange the letters A-Z in ascending and descending order.
Any idea or opinion would be highly appreciated
Re: Programmers In †ђє House Please Help Me Out by Nobody: 10:44pm On Jul 19, 2012
google this "intro to java"
you will be able to write that few hours into the tutorials.

good luck.
Re: Programmers In †ђє House Please Help Me Out by Nobody: 7:11pm On Jul 20, 2012
xteve: I would be grateful if the programmers in the house would help me out.
We were given an assignment in Java to arrange the letters A-Z in ascending and descending order.
Any idea or opinion would be highly appreciated

['A', 'B', 'C', 'D', 'E',' F', 'G' ,'H', 'I', 'J' . . . . . . 'Y', 'Z']

[Z,Y,X,W,V, U,T, S,R,Q'. . . . . 'C' ,'B', 'A']
lol
Re: Programmers In †ђє House Please Help Me Out by teey2(f): 3:07am On Jul 21, 2012
This might be too late but you could import the java util library and use Arrays.sort(array). When you want to print out the array in ascending or descending order, you could manipulate your loop to start printing from wherever you want.

Like for ascending order, start from the very first value: for(int i = 0; i<array.length; i++){System.out.println(array[i])} and for descending order, start from the last value: for(int i = array.length-1; i>=0; i--){System.out.println(array[i])}.
Re: Programmers In †ђє House Please Help Me Out by OgidiOlu3(m): 6:57pm On Jul 21, 2012
U av to type-cast, all character values have their integer equivalents. I've uploaded the .CLASS file for u to compile. If u like it, send me a mail; sijiajayi1@yahoo.com. I'll send u d .JAVA file.

Re: Programmers In †ђє House Please Help Me Out by Nobody: 9:15pm On Jul 21, 2012
@handsomeness, here is the solution using range

result=""
for x in range(65,65+26):
result+=chr(x)
print(result+result[::-1])
Re: Programmers In †ђє House Please Help Me Out by Nobody: 5:01am On Jul 22, 2012
webdezzi: @handsomeness, here is the solution using range

can you break down this code?
Explain what it does please. Tnx.
Re: Programmers In †ђє House Please Help Me Out by StarrMatthieu: 6:21am On Jul 22, 2012
Good job!
Re: Programmers In †ђє House Please Help Me Out by Nobody: 9:54am On Jul 22, 2012
prints A-Z and Z-A in python.
Re: Programmers In †ђє House Please Help Me Out by Nobody: 10:01am On Jul 22, 2012
webdezzi: prints A-Z and Z-A in python.
i really don't get the numbers you inserted within the range() ..lemme try and run it.
Re: Programmers In †ђє House Please Help Me Out by Nobody: 11:27am On Jul 22, 2012
handsomeness:
i really don't get the numbers you inserted within the range() ..lemme try and run it.

each letter of the alphabet has it's corresponding value in numbers, depending on whether you are using Hexadecimal, Decimal, Octa, hept, bin etc
you remember that in maths right?

so i just googled the table and discovered the numbers follow each other, e.g 65=A, 66=B, 67=c etc. to Z
thats luck, if not, i may have to tell range to skip those that dont follow.

so i couldn't remember that particular function that converts numbers to it's alphabet(nerds call it ascii) equivalent, so i contacted google
google reminded me it's "chr".
so range just loops through 26 times, I could just sum up the 65+26 and use 91 there instead, but wanted to be clear on how i arrived at 91

you already know that "+" appends right?

so i printed A-Z and to reverse it, we used list's step, with negative
it's no biggie, result[::-2] will read backward starting from the back in 2 step
so using ::-1 makes it 1 step and that somehow gave us the reverse.

result+result[::-1]
append both

and you have it!


after reading these 2 links you will understand better

http://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Data/ascii.html
http://docs.python.org/release/2.3.5/whatsnew/section-slices.html

1 Like

Re: Programmers In †ђє House Please Help Me Out by Nobody: 7:21pm On Jul 22, 2012
In Ascending order:
class Ascending{
public static void main(String[] args){
for(char ch='a';ch<='z';ch++){
System.out.print(ch+" " );
}
System.out.println();
for(char ch='A';ch<='Z';ch++){
System.out.print(ch+" " );
}
}
}
Do the reverse for descending....
Re: Programmers In †ђє House Please Help Me Out by Nobody: 7:54pm On Jul 22, 2012
Shollypopz: In Ascending order:
class Ascending{
public static void main(String[] args){
for(char ch='a';ch<='z';ch++){
System.out.print(ch+" " );
}
System.out.println();
for(char ch='A';ch<='Z';ch++){
System.out.print(ch+" " );
}
}
}
Do the reverse for descending....


....Oh Yeah Huh?...nice

1 Like

Re: Programmers In †ђє House Please Help Me Out by Nobody: 3:15am On Jul 23, 2012
Shollypopz: In Ascending order:
class Ascending{
public static void main(String[] args){
for(char ch='a';ch<='z';ch++){
System.out.print(ch+" " );
}
System.out.println();
for(char ch='A';ch<='Z';ch++){
System.out.print(ch+" " );
}
}
}
Do the reverse for descending....
cool.. A female Java programmer?! Believe me- i've never met one. Nice coding.
Re: Programmers In †ђє House Please Help Me Out by Lisa1: 8:04am On Jul 23, 2012
Good point
Re: Programmers In †ђє House Please Help Me Out by xteve(m): 11:04am On Jul 24, 2012
@all
Thanks, I really appreciate, u guys hv done ♏ε̲̣̣̣̥ proud

(1) (Reply)

. / Android Studio Introduction - Connect To A Group Chat Via Android - Beginners / Want To Convert Vb.net App To Android

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 30
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.