Results 1 to 2 of 2
Thread: need help with scanner
- 04-18-2008, 02:56 AM #1
Member
- Join Date
- Apr 2008
- Posts
- 1
- Rep Power
- 0
need help with scanner
im currently writting a program with the aim of encoding a string.
"The program is to implement a simple encryption program. The user will be asked four questions:
• The String they wish to have encoded (which may contain spaces).
• The character you'd like used to seperate words in the output (to be stored in a char).
• The number of letters to shift each letter by (to be stored in an int variable).
• Whether or not punctuation is to be repeated in the output (to be stored in a boolean variable).
The answers to these questions will be used to encrypt the given uncoded string (once it has been capitalised), and the resulting coded string will be displayed on the screen."
so far i have managed to come up with this;
import java.util.Scanner;
and i am unable to figure out how to change the ascii values of the letters in the string. im guessing i need to convert the string to a char???Java Code:public class AssigOne108 { public static void main(String[] args) { Scanner sc; String word, delimiter, punc; int shiftAmount, length, rightPos; char punc1, delim, text, letter; boolean pass; sc=new Scanner(System.in); { System.out.println("enter a word/phrase that you wish to encrypt"); word = sc.nextLine(); System.out.println("enter your desired delimiter"); delimiter = sc.nextLine(); delim = delimiter.charAt(0); System.out.println("enter the number of letters to shift the code"); shiftAmount = sc.nextInt(); System.out.println("would you like to include punctuation? true/false"); pass = sc.nextBoolean();} word = word.toUpperCase();} }
:confused:
- 04-22-2008, 01:41 PM #2
Similar Threads
-
how to use Scanner with a number
By cew27 in forum New To JavaReplies: 10Last Post: 04-03-2009, 06:23 PM -
MixedTypeInput example (Scanner)
By Java Tip in forum Java TipReplies: 0Last Post: 01-18-2008, 02:11 PM -
Scanner class
By ajaymenon.k in forum Advanced JavaReplies: 1Last Post: 11-26-2007, 07:01 AM -
Using ava.util.Scanner
By Java Tip in forum Java TipReplies: 0Last Post: 11-20-2007, 04:47 PM -
help with IP scanner
By tommy in forum New To JavaReplies: 1Last Post: 08-06-2007, 08:00 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks