Question
Asked Feb 25, 2019
64 views

Design a program that prompts user enters user name and password. Until user entered user name as "FakeUser", prompts user enters password. Display "Welcome, FakeUser" and until user entered correct password "Secret@123".  The program should also display the number of times user tried to get the correct user name and password.

 

Can anybody provide me step by step solution for this problem?

check_circle

Expert Answer

Step 1

Note:

The programming language is not mentioned in the question. So, it is programmed in Java.

Step by step solution:

  • Define the class “Test”
  • Define the main class.
  • Declare the required variables
    • Get the username from the user using the scanner class
      • Check whether the user entered name equals to “FakeUser”
    • Get the password from the user using the scanner class
      • Check whether the user entered password equals to “Secret@123”
    • Print the greeting message.

 

Step 2

Program:

//Import required package
import java.util.Scanner;

//Definition of class "Test"
public class Test
{
//Definition of main class
public static void main (String[] args)
{
//Declare the variables
String userName= "", pass = "";

//Declare and initialize the count variable
int ucount=0, pcount = 0;

//Crate an object for scanner class
Scanner sc = new Scanner(System.in);
do
{
//Increment "ucount"
ucount++;

System.out.println("Please enter your name:");

//Prompt the name from the user
userName = sc.nextLine();

//Check whether the user "FakeUser"
if((userName.equals("FakeUser")))
{
//Use do..while loop
do
{
//Increment "pcount"
pcount++;

//Prompt the password from the user
System.out.println("Please enter ...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: how to write a function in python 3 that take a tuple t = (7,8,4,20,11) and returns a list which inc...

A: Note: The below program has been complied and executed in “repl.it” online complier

question_answer

Q: I am trying to write a program to convert an integer to a hexadecimal. How do I do this without us...

A: As there is no particular programming language mentioned, we are doing this conversion of integer nu...

question_answer

Q: make the Matlab code for the given question no 5 and 6

A: Note: This program is compilde and executed in MATLAB/OctaveThe program has the following algorithm:...

question_answer

Q: I need help with creating a main.css, I already have the HTML.the details are in the pic and I will ...

A: You can use following code in your main.css file to format your HTML document.Note: Make use of <...

question_answer

Q: How can I create a decoder and a multiplexer in a circuit? The decoder has a 3 bit select input and ...

A: A decoder is a circuit which has n inputs and 2n outputs. So if there are 3 inputs to a decoder it w...

question_answer

Q: I am trying to convert a string in hexadecimal to an integer, or it's decimal value. For example A6 ...

A: As there is no particular programming language mentioned, we are doing this conversion of string in ...

question_answer

Q: I have a question about blockchain technologies. The question states "Describe three components of b...

A: Solution:Blockchain technologies:Blockchain is a technology which permits the digital data to be dis...

question_answer

Q: Question 2 3 4

A: Question 2:Given binary value = 11012   The given binary value does not represents the decimal numbe...

question_answer

Q: Construct npda that accept the following languages on Σ = {a, b, c}: L = {anb3n : n ≥ 0}.

A: To construct the NPDA of the language L = {anb3n : n ≥ 0} on Σ = {a, b, c}, we will draw a machine l...