Unformatted text preview:

CS 110 Introduction to Computer Science Outside Class Programming Assignment I Due At the Start of Class Friday Sept 26 2008 Encrypting Four Letter Words You are to write a program which encrypts four letter words clean words are also acceptable by using character replacement Your program should accept a four letter word from the user and randomly generate letters to replace each letter in the word thereby encrypting the word To do this you will need the String functions of replace and charAt From the Math library you will need the function random This program will also require type conversions Plan Input the word Generate a number between 97 and 122 To do this generate an integer between 0 25 then add 97 to it Replace the first character recall this is character 0 in the word with generated character Repeat the generate and replace for characters 1 2 and 3 Display the encrypted word You are to turn in at the start of lecture a gnulisting of your program and email a copy of your source to your lab instructor and only your lab instructor by 8am on Friday Sept 26 2008 Begin Jumble java 1 2 import java util Scanner 3 import java lang Math 4 5 public class Jumble 6 7 8 public static void main String agrs 9 10 11 String word 12 int length 13 int changeIt 14 char let relet 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 Scanner sc new Scanner System in System out print enter a 4 letter word word sc next length word length changeIt int Math random 26 97 System out println the random char is changeIt let char changeIt relet word charAt 0 word word replace relet let System out println the encrypted word is word changeIt int Math random 26 97 System out println the random char is changeIt let char changeIt relet word charAt 1 word word replace relet let System out println the encrypted word is word changeIt int Math random 26 97 System out println the random char is changeIt let char changeIt relet word charAt 2 word word replace relet let System out println the encrypted word is word changeIt int Math random 26 97 System out println the random char is changeIt let char changeIt relet word charAt 3 word word replace relet let System out println the encrypted word is word Compilation Successful End Jumble java CS 110 Introduction to Computer Science Outside Class Programming Assignment I Due At the Start of Class Wednesday Feb 11 2009 Write complete JAVA Programs to solve 19 on page 117 and the following problem In a new computer assisted board game moves are determined by selecting a random number However players can influence their moves by taking a risk The player selects a random number n between 1 10 The computer then generates a random integer r from 1 to 10 The player s move is then r n 1 n A cautious player selects 1 and always moves forward An ambitious player selects higher numbers and may move forward or backwards Write a program to determine one move in the game Display the computer s number and the move On or before Wednesday Feb 11 2009 you are to create a compiled listing of both programs using gnulist javac programName a2ps or gnulist javac programName programName txt and then print the file programName txt and turn in the hardcopy at the start of class You are to email the source code to both programs to your lab instructor and only your lab instructor prior to 10am Wednesday Feb 11 Begin Game java 1 Sample Program CS 110 Solution to 2 Outside lab Assignment I 3 Spring 2009 4 5 6 7 import java util Scanner 8 import java lang Math 9 10 public class Game 11 12 public static void main String args 13 14 Scanner sc new Scanner System in 15 16 17 18 19 20 21 22 23 24 randNum 25 26 27 28 int randNum playerNum move System out print Enter a number between 1 and 10 playerNum sc nextInt randNum int Math random 10 1 move randNum playerNum 1 playerNum System out println The random number generated was System out println The move resulting was move Compilation Successful End Game java Begin Page117 19 java 1 Sample Program CS 110 Solution to 2 Outside lab Assignment I 3 Spring 2009 4 5 6 7 import java util Scanner 8 9 public class Page117 19 10 11 public static void main String args 12 13 Scanner sc new Scanner System in 14 15 String first second third 16 17 System out print Enter the first string 18 first sc nextLine 19 System out print Enter the second string 20 second sc nextLine 21 System out print Enter the third string 22 third sc nextLine 23 24 System out println The six permutations are 25 System out println first second third 26 System out println first third second 27 System out println second third first 28 System out println second first third 29 System out println third second first 30 System out println third first second 31 32 33


View Full Document

WVU CS 110 - Outside Class Programming Assignment I

Loading Unlocking...
Login

Join to view Outside Class Programming Assignment I and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Outside Class Programming Assignment I and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?