Display Shows:

My Language:

APCS Java

OOP Java for the AP CompSci A Test Starting Code: import java.util.Scanner; /** * Simple Polyalphabetic Cryptography * * @Chris Thiel * @28 Feb 2009 */ public class VignereCipherStartingCode { private static final String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; private static int nextChar(String k, int i){ i=i%k.length(); String letter=k.substring(i,i+1); ...

OOP Java for the AP CompSci A Test Starting Code: import java.util.Scanner; /** * Simple Polyalphabetic Cryptography * * @Chris Thiel * @28 Feb 2009 */ public class VignereCipherStartingCode { private static final String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; private static int nextChar(String k, int i){ i=i%k.length(); String letter=k.substring(i,i+1); return alphabet.indexOf(letter); } public static String encode (String m, String k){ String result=""; for (int i=0; i<m.length(); i++){ int offset=nextChar(k, i); String letter = m.substring(i,i+1); int newLetterIndex= alphabet.indexOf(letter)+offset; newLetterIndex=newLetterIndex % 26; result+=alphabet.substring( newLetterIndex, newLetterIndex+1); } return result; } public static String decode (String m, String k){ String result=""; return result; } public static void main(String[] args) { Scanner kb=new Scanner(System.in); System.out.print("Type a key: "); String key=kb.nextLine(); key=key.toUpperCase(); key=key.replace(" ","");//omit spaces System.out.print("Type a message: "); String message=kb.nextLine(); message=message.toUpperCase(); message=message.replace(" ",""); System.out.println("Using the key \""+key+"\" on \""+message+"\":"); String codedMessage=encode(message,key); System.out.println("Coded="+codedMessage); System.out.println("Decoded="+decode(codedMessage,key)); } } * 8 points: Complete the decode method so it can decipher the Vignere Cipher * 9 points: Adapt this so it can do a Progressive Polyalphabetic Cipher rather than a key * 10 points: Adapt the CarTalk Employee Applet's graphic user interface so that you can type a message in one text area, press a button and it shows the encoded text (using the Progressive Cipher), press another button and it shows the decoded text. * 11 points: Add a "key field" to the Applet, and use the Vignere Cipher, working in a similiar fashion as the 10 point version

Show all Visit Show Website http://apcsjava.blogspot.com/

Recently Aired


  • HD

    Make a Java Class for Dots

    Make a new object that represents a dot using the ...

    Make a new object that represents a dot using the eclipse IDE.

    Sep 4, 2011 Read more
  • HD

    Making a JAR file in Eclipse

    If you want to publish your Applet to the web, ...

    If you want to publish your Applet to the web, you probably need to make a Java Archive, or JAR file that allows you to embed your Applet in a web page

    May 23, 2011 Read more
  • HD

    Interfaces Part 3

    Implementing java interfaces for any Object. For "starter" code see ...

    Implementing java interfaces for any Object. For "starter" code see the APCS Wiki

    Feb 21, 2011 Read more
  • HD

    Java Interfaces Parts 1 and 2

    We introduce a way to use code to work with ...

    We introduce a way to use code to work with a variety of classes using interfaces. Source code can be found at the APCS Wiki

    Feb 21, 2011 Read more
  • HD

    Starting APCS with linux

    Aug 21, 2010
  • HD

    Cryptography

    Starting Code: import java.util.Scanner; /** * Simple Polyalphabetic Cryptography * ...

    Starting Code: import java.util.Scanner; /** * Simple Polyalphabetic Cryptography * * @Chris Thiel * @28 Feb 2009 */ public class VignereCipherStartingCode { private static final String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; private static int nextChar(S

    May 14, 2010 Read more
  • HD

    PokerHand

    To make a variety of Poker games, we need a ...

    To make a variety of Poker games, we need a way to evaluate and compare Poker hands. This video also shows how to implement an interface in an inner class, so that a user can press a button, and new poker hands are generated. Starter code can be found at

    Nov 28, 2009 Read more
  • HD

    Making Classes with the Eclipse IDE

    Make mew Projects and Classes in Eclipse.

    Sep 7, 2009
  • HD

    Dr Java interactions

    Click on the title to see the video. Here I ...

    Click on the title to see the video. Here I show how to try the code snippets that you will see while reading Chapter 2 of Horstmann, "Java Concepts"

    Aug 23, 2009 Read more
  • HD

    Cheater Catcher Intro

    Overview of how to design a program that checks for ...

    Overview of how to design a program that checks for patterns of matching words to detect plagiarism.

    Jan 20, 2009 Read more
Loading...