Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 458659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:41:37+00:00 2026-05-12T22:41:37+00:00

I have a simple problem that says: A password for xyz corporation is supposed

  • 0

I have a simple problem that says:

A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string and print out a message as to whether or not the string entered would be considered a valid password.

I need help on completing this code. I have this pseudocode that I can’t workout into Java code:

print "enter new password"
input newPassword
digitCounter =0
letterCounter = 0
for I = 0 to newPassword.length() by 1
    c = newPassword.charAt(i)
    if c is a digit
        increment digitCounter
    else if c is a letter
        increment letterCounter
    endif
endFor
if newPassword.length() >= 6 and digitCounter > 0 and letterCounter > 0
    print "the password is valid"
else
    print " password rejected, must be at least 6 characters long and be a mix of letters and digits "
endif

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

So far all I have is this for the Java code:

import java.util.Scanner;

public class Password 
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);

        String thePassword;

        int len, i, letterCounter = 0, digitCounter = 0;
        char c;

        Len = thePassword.length();

        System.out.print("Enter the password: ");
        thePassword = in.nextLine();

        for (i = 0,i = len, )
        {
            c = in.charAt(1);

            if ()
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:41:38+00:00Added an answer on May 12, 2026 at 10:41 pm

    Take a look at Character.isDigit() and Character.isLetter() for checking the characters:

    If you want to use String.charAt() to get the characters of your string, you could do a for loop like so:

    for (int i = 0;i < s.length();i++) {
        char c = s.charAt(i);
        //Check things about c
    }
    

    Although Java 1.5 instroduced a For-Each loop which will loop automatically over arrays like so:

    for (char c : s.toCharArray()) {
        //Check things about c
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple problem that I have not been able to find an
I have a simple problem that I've been stuck on for some time and
I have a simple problem that i cannot solve. I have a dictionary: aa
I have a very simple C# DataTable problem that I cannot seem to wrap
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have a computational geometry problem that I feel should have a relatively simple
I have a pretty simple problem. Basically I have an array called $list that
I have a problem that is quite simple to understand, but for me it
This seems like a simple problem: I have a WF4 activity that guides the
I've made a simple project to illustrate my problem. I have a user control

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.