Decoder Ring - Prompt User For A Message To Decode

Nov 7, 2014

So it is the question: This program implements a simple "decoder ring". It will prompt the user for a message to decode and decode the message based on the following substitution rules:

ABCDEFGHIJKLMNOPQRSTUVWXYZ will map to
ZEBRASCDFGHIJKLMNOPQTUVWXY

abcdefghijklmnopqrstuvwxyz will also map to
ZEBRASCDFGHIJKLMNOPQTUVWXY

any other characters (like space, punctuation, will map to themselves)

so if it sees an 'A' (or an 'a'), it will map to 'Z', etc... All i could think of is this but can't figure out the rest.

import java.util.Scanner;
public class DecoderRing
{
public static void main(String[] args)
{
String1[] = 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z';
String2[] = 'Z','E','B','R','A','S','C','D','F','G','H','I','J','K','L','M','N','O','P','Q','T','U','V','W','X','Y';
}
}

Not sure, what things are necessary such as switch statements or if and else or for loops and such...

View Replies


ADVERTISEMENT

Result Of Encoded Message Cannot Restore To Original Message By Decoder

Sep 28, 2014

The problem is the result of encoded message can't not restore to the original message by the decoder. Here are my three class's code

SecureMsgMain:

package securemsg.core;
 
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
 import securemsg.database.*;
 public class SecureMsgMain {
 
[Code] .....

View Replies View Related

Caesar Cipher - Encode / Decode Message With Given Key

Nov 1, 2014

I have been assigned to make a program that encodes and decodes a given message with the given key (spaced numbers, for example: 3 1 7 4 2 5). I'll post the code for all the classes that I am using below.

QueueInterface:

import java.util.*;
public interface QueueInterface<T>
{
T dequeue() throws QueueUnderflowException;
boolean isEmpty();

[Code] ....

Ok, so the classes to focus on are these:

CircularLinkedUnbndQueue
CircularLinkedQueueITD
Encoder
Decoder
EncodeDecodeConsole
EncodeDecodeITD

Because those are the ones I had to write myself, the others were given to us to use. As far as these classes go, they work fine without causing any errors from the input I give. For example if I enter a message and a key, it correctly encodes and decodes the message with the given key. What I'd like for you fine programmers to do is give feedback on those 6 classes. Like, suggestions on how to make them better or more efficient, neater, changing any of the methods to make them more efficient or prevent any errors beforehand, etc.

View Replies View Related

Using String Tokenizer And Buffer To Decode A Message?

Apr 15, 2014

So I have this file in which has a few sentences on a single line. What I need to be able to do is read the file and then take each word and create a token out of it. Then what it does is it selects the first letter of every 5th word, uppercase it, and then allow me to use append it via a stringbuffer object to create a word out of it.

I know I'll need to use a string tokenizer but I'm not sure how to do so in a way that makes each word separate and how to tell it to only hit the 1st letter of every 5th word.

Here's what I've come up with so far, but I'm currently at a loss at what to do and my textbook/documentation is just not working.

Java Code:

String line; // The line we read from the file.
char letter; // The first letter of each 5th word.
String sw; // The completed string.
public static void main (String [] args)throws IOException {

[Code] ....

View Replies View Related

Prompt User For Integer To Make Sure Length Entered By User Is A Power Of 2

Oct 8, 2014

Basically I need to make a program prompts the user for an integer, check to make sure the length entered by the user is a power of 2 and at least 2. Then I need to convert from base e to base 2 then I need to print the tick marks of a ruler based of the value of the length.

I got the whole converting thing working and the check for a power of 2, that wasn't an issue because it didn't require any recursion. I just don't know how to print out the proper tick mark values.

The way it is supposed to work is that it needs to look like this. Say the user enters 8;

012131210
012345678

Or if the user enters 16;

01213121412131210
01234567890123456

The bottom row is pretty much just the index value, that I print fine.

The top row though is supposed to be the length of the ticks on a ruler, with the middle most value being the value of the conversion from base e to base 2 from above. I can get that printed and what I get just looks like this.

For 8;

000030000
012345678

For 16;

00000000400000000
01234567890123456

As you can see I can get the middle value and the index values below but I don't know how to use recursion to get the right numbers.

Here's my current code.

import java.util.*;
public class TickMarks {
public static void main (String args[]){
Scanner input = new Scanner(System.in);
boolean looping = true;
while(looping == true){
System.out.print("Please enter a length: ");

[Code]...

Now the methods isPowerOfTwo() and printLength() both work fine. However, I'm not sure how to get the left and right side working.

My thoughts were to split the length in half and get a left and right side. I gave both of them arrays so I can keep track of the values. Now as you've seen above I get all zeros and I know it's because that's the default value in an array, I just don't know how to get the proper values.

View Replies View Related

EJB / EE :: J2EE Sending Message / Email From Registered User To Another User

Mar 3, 2015

I am a first-timer using J2EE and here on coderanch.com and wanted to make a Simple Email-like System which a Registered User can Send Message/Email to another Registered User. how to do it. I have already my register/login process done but I'm stuck on how to make the Email. And I have an sample Bootstrap for my UserInterface which I want to use.

View Replies View Related

Random Number With User Prompt?

Sep 8, 2014

I am wanting this program to prompt the user to enter a maximum value and a minimum value and the program should in theory generate a random number for the output. Here is my logic:

int maxRange1;
int minRange1;
static int range;
static Random gen;

Then in my mail argument:

gen = new Random();
Scanner input = new Scanner(System.in);
System.out.print("Enter the maximum number: ");
int maxRange1 = input.nextInt();

[Code] ....

I am able to return both the user prompts and get the inputted answer to appear but I am not getting a response for the prompt "The random number is: ".

View Replies View Related

Prompt User To Enter A String

Feb 15, 2015

I am suppose to design a problem the prompts the user to enter a String. Based on the input from the user, have the program prompt with a full description of the playing card entered. Below is a table of the notation and meaning:

Notation Meaning
A Ace
2...10 Card Values
J Jack
Q Queen
K King
D Diamonds
H Hearts
S Spades
C Clubs

Use the .charAt(...) to extract each character from the user's input and build a switch statement to determine the full description.

import java.util.Scanner;
public class PlayingCardIdentifier {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter a card notation: ");
String s = input.nextLine();

[code]...

View Replies View Related

Insert While-loop To Prompt User For Yes Or No

Apr 15, 2015

public static void getInput(int [] student, int []test1,int []test2,int []test3,
int [] test4, int [] test5) {
int stuId = 0;
int t1 = 0;
int t2 = 0;
int t3 = 0;
int t4 = 0;
int t5 = 0;
int h = 0;
char answer = '@';

[Code] ....

View Replies View Related

DiceSum - Prompt User For A Desired Sum

Nov 16, 2014

Write a method named diceSum that prompts the user for a desired sum, then repeatedly rolls two six-sided dice until their sum is the desired sum. Here is the expected dialogue with the user:

Desired dice sum: 9
4 and 3 = 7
3 and 5 = 8
5 and 6 = 11
5 and 6 = 11
1 and 5 = 6
6 and 3 = 9

This is my code:

import java.util.Scanner;
import java.util.Random;
public class mod {
public static void main(String[] args) {
diceSum();

[Code] .....

it works for numbers 2 - 4, but any number from 5 - 12 just prints one output, which is not the correct desired sum.

View Replies View Related

Prompt For User Input At The End Of First Loop

Mar 3, 2014

I am having a problem with code that I've written, the problem occurs when I try to prompt for user input at the end of the first loop. What happens is the println fires but the prompt never does and it exits the loop.

Java Code:

import java.util.Scanner;
public class Lab3test
{
public static void main( String[] arguments )
{
//Variable declaration

[Code] ....

View Replies View Related

Code Up With A Loop That Prompt User To Say If Program Should Run Again

Sep 10, 2014

I am still relatively new to java and am working on a lab program. I have already met the requirements and am trying to spice my code up with a loop that prompts the user to say if the program should run again. This is what I have so far:

package lab2;
import java.util.Scanner;
public class OrderedPairTest{
public static void main(String[] args){
boolean retry = true;
while(retry == true){

[code]....

However, it is giving me an error after the user inputs "y" in for the answer to run again. What did I do wrong?

Error code is: Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Unknown Source) at lab2.OrderedPairTest.main(OrderedPairTest.java:11)

View Replies View Related

Prompt User To Enter Integer From 1 To 15 And Displays A Pyramid

Jun 1, 2014

The exercise sounds like this : Write a program that prompts the user to enter an integer from 1 to 15 and displays a pyramid , as shown in the following sample run (my code displays correctly the first 9 lines):

1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5
6 5 4 3 2 1 2 3 4 5 6
7 6 5 4 3 2 1 2 3 4 5 6 7

The problem is when i input a number greater then 9 as it requires 2 spaces . I m pritty sure i solved it incorrectly or at lost not optimal as i m using a string that decreases on each line to create the pyramid effect.

import java.util.*;
public class C5_17 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the number of lines: ");

[Code] ....

View Replies View Related

Prompt A User To Enter Three Tasks And Their Priorities In A Driver

Oct 31, 2014

My full instructions are to Design a Java interface called Priority that includes two methods and two constants. The methods are setPriority and getPriority. The constants are MIN_PRIORITY with value 1 and MAX_PRIORITY with value 6. The interface should define a way to establish numeric priority among a set of objects. Design and implement a class called Task that represents a task (such as on a to-do list) that implements the Priority interface. Assume that Task has two attributes (instance data): name and priority. Define the Task constructor to accept and initialize the name of the task. Each newly created Task should have priority equal to MIN_PRIORITY (the constructor should initialize priority to MIN_PRIORITY). Priorities can be changed using setPriority method. Create a driver class TaskDriver that should do the following: prompt the user to enter three tasks and their priorities, and then print the tasks in the order of decreasing priorities. If the user enters an invalid priority that is less than MIN_PRIORITY or greater than MAX_PRIORITY, then the user should be asked to enter priority again until a valid priority value is entered.

So far I have:

public interface Priority
{
public void setPriority(int level);
public int getPriority();

[Code].....

View Replies View Related

Prompt User To Enter Value Of Their Savings For N Number Of Weeks

Oct 19, 2014

So I have this program where i have to prompt user to enter a the value of their savings for n number of weeks (quarters dimes nickels pennies) and the program outputs the total of savings an average of saving per week and an estimation of saving per year.

I managed to do the first step but the problem is that when they enter the value of their savings i don't know how to save the value of each(quarters dimes nickels and pennies) to make the calculations? Here is what i have so far

import java.util.Scanner;
 public class yearlySavings
{
 public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
int numberOfWeeks = 0; // initialize value of numberOfWeeks
 
[Code] .....

View Replies View Related

Search Matrix For The Element With Highest Value - Prompt User With Location

Feb 11, 2015

I have to create a program that asks a user to enter an amount for rows and an amount for columns. After they input both amounts, they must fill in the matrix with values (values of double data type). After they enter the values, the program is suppose to search the matrix for the element with the highest value. Once it is found, the user will be prompted with the location of the highest value within the array. I got it to work as to where the user inputs the values and he/she will receive a location of an element. However what they receive is incorrect.

For example

"Enter number of rows: 3
Enter number of columns: 4
Enter values: 23.5 6 13 2
1 5 6 3
7 5 9 2"

Once they enter the last value, they will be prompted with

"The highest element is located in 34".

As you can tell, the highest element is located in 01. I think when the user is prompted with the values that they enter for the rows and columns. How can I modify my code as to where it shows the actual location of the highest value?

View Replies View Related

Test Program That Prompt User To Enter N And Displays N-by-b Matrix

Nov 25, 2014

I did a problem from my book which is "Write a method that displays an n-by-n matrix. Each element is 0 or 1, which is generate randomly. Write a test program that prompts the user to enter n and displays the n-by-b matrix".

So if a user would enter 3, and output could be 0 1 1
0 1 0
1 0 1

So here's my question... I was able to get the program to work in the way my book describes (by just writing the code in the class with the main), but for practice, I want to learn how to do this OOP-style...

I'm not sure how to do this, though, since the method is a void method, so I can't seem to call it within a toString method.

import java.util.Scanner;
public class MatrixTest {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter an int");
int number = input.nextInt();
MatrixClass mc = new MatrixClass(number);

[Code] .....

View Replies View Related

Prompt User To Input Integer And Then Output Both Digits Of Number And Their Sum

Jun 7, 2015

Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. 
 
Now I have a code for spacing out the integers, and I have a separate code for adding the digits. But I am not sure how to merge them together. Both of them work independently
 
Spacing code:
import java.util.*;
public class SumoftheIntegers
{
static Scanner console=new Scanner(System.in);
public static void main(String []args) {
int num1, test, rem;
int counter = 0;

[Code]...

Now the sum of the integers code:
 
import java.util.Scanner;
public class sum
{
    public static void main(String[] args)
    {
        // Create a Scanner
        Scanner input = new Scanner(System.in);
// Enter amount
        System.out.print("Enter an integer: ");
        int integer = input.nextInt();

[Code]...

View Replies View Related

Prompt User For Input Number And Check If It Is Greater Than Zero - Java Multiplication

Apr 13, 2014

Write a program that prompts the user for an input number and checks to see if that input number is greater than zero. If the input number is greater than 0, the program does a multiplication of all the numbers up to the input number starting with the input number. For example if the user inputs the number 9, then the program displays the following sum:

9 * 8 * 7 * 6 * 5 * 4 * 3 * 2 * 1 = 362880

That's the question I'm getting and so far all I've got is

import java.util.Scanner;
public class Lab4Q3
{
public static void main (String[] args)
{
int keyboard;

[Code] .....

View Replies View Related

Add Integers To ArrayList And Prompt User To Delete Specific Numbers Not Required

Jan 21, 2015

This program simply adds integers to an ArrayList and then prompt the user if they would like to delete specific numbers that they don't want.

The output that I get when I want to delete numbers like 2 and 4 from 1 2 3 4 5 is 1 2 3 4 5 instead of 1 3 5.

Java Code:

import java.util.ArrayList;
import java.util.Scanner;
public class AL
{
// A regular array like int arr[] has to have its size declare before run-time and it's not dynamic which mean it can not grow or expand on its own.
static Scanner input = new Scanner(System.in);
// You have to use reference types(Integer, Double, Float); not primitive types(int).

[Code] .....

View Replies View Related

Smoothing Input Using Ring / Circular Buffer?

Aug 11, 2014

Normally I would just implement a circular buffer and be happy but there's a fundamental problem with that.OK, so I'm working on a piece of cheap Android hardware that's being used for demo purposes. One of the problems, primarily because it's cheap (imo) is that the screen input is not clean and is interfering with the UI experience. Specifically when gliding your finger, the result is quite non linear.

I know that's not the best drawing but it sort of explains the problem to a degree. In reality, it's probably a bit smoother than that, but there is still noisy data getting in, and the problem is it causes the UI to be jittery at times.

I would like to smooth this using something like a Circular Buffer. Now I figured the best way to do this would be to store the last 4 float inputs and then effectively calculate the next value based on an average, so say our input was this:10, 15, 20, 25 and 35 is the current input.

15 - 10 = 5
20 - 15 = 5
25 - 20 = 5

Then for the next value, 35 - 25 = 10. 10 + (3 * 5) = 25 / 4 = 6.25...Then adding 6.25 to the previous value resulting in this: 10 15 20 25 31.25 which would appear theoretically smoother. However I'm struggling to work out in my head the best way to implement such a function.

View Replies View Related

How To Compare Int To A Empty String To Input Error Message To User

Apr 16, 2015

I made a guess a number program but I am having issue figuring out a way that when a user enter's in nothing for the program to spit out a message saying "hey entering nothing doesn't work try again" then ask for input. I have done some research and from what I have found is to read the input in as a String rather than int, and use something like Integer.valueOf() to get the integer value but I am completely lost on how to apply that to my program here is my code

//import statements
import java.util.*; //for scanner class
// class beginning
public class Guess {
public static void main(String[] args ) {
//Declare variables area
int guess, secretNumber = (int) (Math.random() * 10 + 1), lowGuess,highGuess;

[Code] ....

View Replies View Related

How To Make Shift Encoder / Decoder

Oct 16, 2014

I am working on a project where we need to make a shift encoder/decoder. Right now I am working on my prepareString method, and I have no way of testing it yet. I was just wondering if I wrote it correctly. It should pull in the user entered string and check if each character is a letter, and remove all that are not. Then it should turn all the letters to upper case. Based on that does this look right?

private String prepareString(String plainText)
{
int strLength = plainText.length();
for(int i = 0; i < strLength; i++)
{
char c1 = plainText.charAt(i);
boolean isLetter = Character.isAlphabetic(c1);
if(isLetter == false)

[Code]...

View Replies View Related

Java Binary Encoder And Decoder Program

Aug 2, 2014

I have made a Java Binary Encoder and Decoder program and, to date, this is the program I have spent the most time developing.

I have ran Alpha tests to check the functionality is correct and it appears to work well. However I am more interested in the quality of my code ,

The code can be found over at: [URL] ....

View Replies View Related

Encode / Decode A Jar File In Java

Feb 13, 2014

how to decode a .jar file to view its methods and later encode it. i wanted to write the program in java instead of using winzip

View Replies View Related

String Encode / Decode Method

Apr 4, 2014

I was asked to write program in Java, that should code and encode some String in following way:

i) coding : "rrryyyyyaaaa" -> "r3y5a4"
ii) encoding: "r3y5a4" -> "rrryyyyyaaaa"

The code works fine, but I forgot the name of this coding method.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved