Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am trying to create this java program -------My code---- import java.util.Scanner; import java. util.Random; public class Main { public static void main(String[] args) {

I am trying to create this java program

image text in transcribed

-------My code----

import java.util.Scanner; import java. util.Random; public class Main { public static void main(String[] args) { // Generate a alphabet as a two-digit string Random r = new Random(); String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; int length = 5; // Prompt the user to enter a guess Scanner input = new Scanner(System.in); System.out.print("Enter your guess pick (two characters): "); String guess = input.nextLine(); // Get letters from alphabet char alphabetDigit1 = alphabet.charAt(0); char alphabetDigit2 = alphabet.charAt(1); char alphabetDigit3 = alphabet.charAt(2); char alphabetDigit4 = alphabet.charAt(3); char alphabetDigit5 = alphabet.charAt(4); // Get letters from guess char guessWord = guess.charAt(0); char guessWord2 = guess.charAt(1); for (int i = 1; i  

when it compares the characters that the user has inputted it keeps saying both are wrong.

image text in transcribed

Is there anyway to fix this?

Take two alphabet characters from a user and compare them with your first and last characters out of five random characters. Enter your guess pick (two characters): jif Mine is aBoth are wrong Mine is EBoth are wrong Mine is DBoth are wrong Mine is kBoth are wrong Mine is MBoth are wrong

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

Discuss the advantages and disadvantages of the gold standard.

Answered: 1 week ago

Question

Prepare an ID card of the continent Antarctica?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago

Question

2. Discuss the steps in preparing a manager to go overseas.

Answered: 1 week ago