I have to write a program that reads a string of letters from the english language and of at least 5 characters then converts it to uppercase and
1. prints the string in uppercase
2. prints the unicodes (as integer numbers) for each of the first 5 characters in the string
3. encode the first 5 characters of the string following the process described below
4. prints the resulting integer number.
* convert each letter into a number between 0 and 25 by replacing each letter by its unicode and then subtract from such code(seen as an integer number) the unicode for the letter A
*e.g. BUTS becomes 1,20,19, and 18.
encode the letters by: 1x26+20=46 46x26+19=1215 1215x26+18=31608
so the resulting integer for BUTS is 31608
Please help me the only thing i can do from this is take a string and print it in uppercase. I have only been programing for 3 weeks and im starting to get lost thank you
import java.io.*;
class homework{
public static void main(String[]args){
System.out.print("Type in the given string please: ");
String five = new String ( input.next());
int j = five;
System.out.println("The string in uppercase is " + five.toUpperCase());
System.out.println("The Unicodes are: " + j);
System.out.println("After encoding the first 5 characters the integer is: ");
}
}
this is all i can do i am completly lost with encoding it, i also dont know if this works because when i try to compile it says error for input.next like it doesnt recognise i.
if anyone could help i would be most greatfull, thank you again.
This post has been edited by Andrew_ahmad: 26 October 2009 - 03:03 PM

New Topic/Question
Reply



MultiQuote



|