0
import java.util.*;
import java.lang.*;
import java.io.*;

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

        //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
                seenChar++;
            }
        }

        //output the answer
        System.out.println("The new Encode is " + newphase);
    }
}
2
Contributors
3
Replies
26
Views
3 Years
Discussion Span
Last Post by Doogledude123
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.