Question

java code.

James needs to create a computer text based game where some user has to enter as many words with the given letters as the given word.

A good start would be writing a method that checks if a method has the same letters as the other.

include pseudo code+

Input-Listen and Silent have the same word

that's all information I have

is a Anagram program that need to be done.ASAP

just help me with the pseudo code of the program. not the actul program just the steps!

Include the pseudocode of the program not the program just the pseudo code of it. Sample Run(Demonstration of what will displ
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Java code

import java.util.Arrays;
import java.util.Scanner;

public class Anagrams {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

       boolean flag = true;
       String word1,word2,op;
       Scanner scan = new Scanner(System.in);
      
       while(flag) {
          
           System.out.println("Enter word 1: ");
           word1 = scan.next();
           System.out.println("Enter word 2: ");
           word2 = scan.next();
          
           if(isAnagram(word1,word2)) {
              
               System.out.println(word1+" and "+word2+" are Anagrams.");
           }
          
           else
               System.out.println(word1+" and "+word2+" are not Anagrams.");
          
           System.out.println("Do you want to enter more word(y/n): ");
           op = scan.next();
          
           if(op.compareToIgnoreCase("n")==0) {
              
               flag = false;
           }
       }
      
      
      
   }

   private static boolean isAnagram(String word1, String word2) {
       // TODO Auto-generated method stub
      
       char[] array1 = word1.toCharArray();
       Arrays.sort(array1);
   word1 = new String(array1);
       char[] array2 = word2.toCharArray();
       Arrays.sort(array2);
       word2 = new String(array2);
       if(word1.compareTo(word2)==0)
           return true;
       return false;
   }

}

Output

Enter word 1:
map
Enter word 2:
ampp
map and ampp are not Anagrams.
Do you want to enter more word(y/n):
y
Enter word 1:
AMP
Enter word 2:
MAP
AMP and MAP are Anagrams.
Do you want to enter more word(y/n):
y
Enter word 1:
lock
Enter word 2:
kocl
lock and kocl are Anagrams.
Do you want to enter more word(y/n):
n

Screenshot

Anagrams.java x while(flag) { System.out.println(Enter word 1: ); word1 = scan.next(); System.out.println(Enter word 2: )

Add a comment
Know the answer?
Add Answer to:
java code. James needs to create a computer text based game where some user has to...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ program: can you help create a autocorrect code using the cpp code provided and the...

    C++ program: can you help create a autocorrect code using the cpp code provided and the words below using pairs, vectors and unordered map: Objectives To practice using C++ std::pair, std::vector, and std::unordered_map To tie together what we've learned into the context of a real-world application used by millions of people every day Instructions For Full Credit You're given a short list of words in known_words_short.txt that contains a handful of very different words. Assume this short list of words...

  • Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in...

    Question 2: Finding the best Scrabble word with Recursion using java Scrabble is a game in which players construct words from random letters, building on words already played. Each letter has an associated point value and the aim is to collect more points than your opponent. Please see https: //en.wikipedia.org/wiki/Scrabble for an overview if you are unfamiliar with the game. You will write a program that allows a user to enter 7 letters (representing the letter tiles they hold), plus...

  • For a C program hangman game: Create the function int play_game [play_game ( Game *g )]...

    For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...

  • Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make...

    Assignment 4 Real Deal: Crier On Us Some word games, like Scrabble, require rearranging a combination of letters to make a word. This type of arrangement is generally referred to as an anagram, it's known as a permutation in mathematics. This assignment will give you some experience thinking about and writing recursive functions. Write a C++ program that searches for ``anagrams'' in a dictionary. An anagram is a word obtained by scrambling the letters of some string. For example, the...

  • For this lab you will write a Java program that plays a simple Guess The Word...

    For this lab you will write a Java program that plays a simple Guess The Word game. The program will prompt the user to enter the name of a file containing a list of words. These words mustbe stored in an ArrayList, and the program will not know how many words are in the file before it starts putting them in the list. When all of the words have been read from the file, the program randomly chooses one word...

  • In C++ Please!!!!! Example main: #include <iostream> #include <fstream> #include <istream> #include <cstring> using namespace std;...

    In C++ Please!!!!! Example main: #include <iostream> #include <fstream> #include <istream> #include <cstring> using namespace std; const int MAXRESULTS = 20; // Max matches that can be found const int MAXDICTWORDS = 30000; // Max words that can be read in int main() { string results[MAXRESULTS]; string dict[MAXDICTWORDS]; ifstream dictfile; // file containing the list of words int nwords; // number of words read from dictionary string word; dictfile.open("words.txt"); if (!dictfile) { cout << "File not found!" << endl; return...

  • Java This assignment will give you practice with line based file processing and scanner methods. Modify...

    Java This assignment will give you practice with line based file processing and scanner methods. Modify the Hours program we did in class. You are going to write a program that allows the user to search for a person by ID. Your program is required to exactly reproduce the format and behavior of the log of execution as follows: Enter an ID: 456 Brad worked 36.8 hours (7.36 hours/day) Do you want to search again? y Enter an ID: 293...

  • 60 points, Complete javadocs documentation required Be sure to submit all files (.java and dictio...

    60 points, Complete javadocs documentation required Be sure to submit all files (.java and dictionary.txt) required to run your program Background Boggle is a word game using a plastic grid of lettered dice, in which players attempt to find words in sequences of adjacent letters. The dice are randomly arranged in the grid, and players have 90 seconds to form as many words as possible from adjacent top-facing letters For example, the word SUPER is spelled in the gameboard to...

  • For this assignment, your job is to create a simple game called Opoly. The objectives of...

    For this assignment, your job is to create a simple game called Opoly. The objectives of this assignment are to: Break down a problem into smaller, easier problems. Write Java methods that call upon other methods to accomplish tasks. Use a seed value to generate random a sequence of random numbers. Learn the coding practice of writing methods that perform a specific task. Opoly works this way: The board is a circular track of variable length (the user determines the...

  • Playing a video game on a computer can give different experiences based on the performance capabi...

    Playing a video game on a computer can give different experiences based on the performance capabilities of the computer’s hardware (typically processor and graphics card – among other things). Developers of a new game will typically have “recommended” specifications for the computer hardware that is required to run their games on a variety of graphics settings (the faster the hardware, the higher the graphics quality). You are being tasked to create a program that will tell a gamer what graphics...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT