import java.util.*;
import java.lang.*;

class EncodeThePhase
    public static void main (String[] args)
        //set up keyboard input
        Scanner scan = new Scanner(;

        //Ask for string from keyboard
        System.out.println("Please input your phase:");
        String input = scan.nextLine();

        //Ask for an offset number 
        System.out.println("Please input your offset integer:");
        int x = scan.nextLine();

        //at the beginning we have not found any instances of the character
        int seenChar = 0;

        //go through each character of input and check to see if it
        //is equal to searchChar
        for(int count = 0; count < input.length(); count++)
            //check if they're equal (we assume searchChar has length 1
            //so we only look at the first character)
            if(input.charAt(count) == searchChar.charAt(0))
                //if they are equal, increase how many times we've seen the character

        //output the answer
        System.out.println("The new Encode is " + newphase);

Recommended Answers

All 3 Replies

Line 13: Spelling Mistake,
Line 18: Scan for Int,
Line 24 - 34: Use For Each, with Char, and a Char Array containing the String

That should get you started.


Glad you got it solved, don't forget to mark the thread as solved!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.