Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Write a program that will prompt for the secret word (which is Terps). If the user puts in Terps, output Correct. Otherwise, let

 

3. Write a program that will prompt for the secret word (which is Terps). If the user puts in Terps, output Correct. Otherwise, let the user know if the word they entered has Less characters than the secret word, the Same amount, or More characters. Use the nextLine() method to read the input and you can assume the user will type in an actual word for the input. The program should be case sensitive (i.e. Terps is not terps) and remember to not use to check if they entered Terps (you should know what to do instead, so don't ask the TA ). You can use the String method length to get the number of characters in a word. For example, the following code would output 5 since hello has 5 characters in it. String s "hello"; System.out.print (s.length()); Here are 4 different sample runs (with user input in italic and output in bold just to make it easier to understand how it works). Enter the secret word: Terps Correct Enter the secret word: hi Less Enter the secret word: table Same Enter the secret word: Penguin More

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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions