View Single Post
  #1 (permalink)  
Old 04-18-2008, 04:56 AM
whiterex whiterex is offline
Member
 
Join Date: Apr 2008
Posts: 1
whiterex is on a distinguished road
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;
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();} }
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???

Reply With Quote
Sponsored Links