15,905,877 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 13676546 (Top 16 by date)
Member 13676546
21-Apr-18 8:57am
View
thanks
Member 13676546
20-Apr-18 20:57pm
View
thanks.
but the array is initialized as 4 , so why does it give this exception
Member 13676546
5-Apr-18 9:56am
View
thanks a lot for the explanation It was very clear useful, It seems I had problem with concatenation .. i thought it the answer would be reverse of abcd.. thanks again!
Member 13676546
13-Mar-18 14:45pm
View
thanks
Member 13676546
13-Mar-18 14:40pm
View
how can i learn to write codes if i ask someone else write them instead of me, so obviously the latter is not what im looking for! however, as i mentioned i need explicit and clear hints, for example at which part there is a problem, hints to correct them, or more important how to analyse and understand the question correctly what does it want and need, possible alternatives..
thanks for reply
Member 13676546
25-Feb-18 0:57am
View
thanks
Member 13676546
24-Feb-18 20:05pm
View
thanks for the hint. I tried to correct it please let me know if I'm in the right direction in writing my method in general, is its logic correct , and then which parts need to be rewritten and hints for them. in this sway I can understand better
public class check{
public static void main(String[] args){
String a = "abc d";
String b= "abcd fe";
System.out.println(compareString(a,b));
}
public static boolean compareString(String a, String b){
// here i try to declare array size i dont know if i can do it in this way ?
String c[]= new String [a.length];
String d[]= new String [b.length];
int i=0;
int j=0;
// here i try to split them and store each char in arrays
for ( i=0; i<=a.length;i++){
String c[i] =a.split[" "];
}
for (j=0;j<=b.length;b++){
String d [j]=b.split()[" "];
}
// here i tried to count matches and add them up plus counting the numer of words
int matches=0;
int numberOfWords=0;
for (i=0;i<=c.length();i++){
for( j=0;j<=d.length;j++){
if (c[i]==d[j]){
matches++;
}
numberOfWords++;
}
}
// here is it correct to write it this way ?
if (match/numberOfwords*100>0.9*100){
return true;
{
return fales;
}
}
}
}
// I tried to fix the errors but it gives another erros ..
2 errors found:
File: C:\Users\Acer\Desktop\check.java [line: 17]
Error: Syntax error on token "i", delete this token
File: C:\Users\Acer\Desktop\check.java [line: 20]
Error: Syntax error on token "j", delete this token
Member 13676546
24-Feb-18 19:29pm
View
thanks for the explanation , below I tried to improve it.
Member 13676546
14-Feb-18 9:31am
View
thanks again for the explanation. it was clear and helpful.
Member 13676546
14-Feb-18 9:01am
View
how can we rewrite it without using array ?
Member 13676546
14-Feb-18 8:53am
View
I have not learnt array yet. and your guess is not correct. I have studied the topic and I know since it is new I need to practice more to grasp the concepts. I'm also here to get help in my coding not being judged.
Member 13676546
14-Feb-18 8:37am
View
thanks a lot for debugging it ( is it the correct to say like this ?) the only thing is I cannot use array.
Member 13676546
14-Feb-18 8:32am
View
thanks for the link, however, I'm beginner, and I just learnt conditional loop and a bit of string very basics.. not anything else, the goal of the exercise is to write a method and call it. we can not use scanner in the method but we ca verify the result ( which should be Boolean type) through the main method. so I need to write a program to validate a password with the basics.
Member 13676546
13-Feb-18 20:07pm
View
Deleted
it does not compile it still give errors.
import java.util.Scanner;
public class PasswordValidator {
public static void main (String[] args){
Scanner input= new Scanner (System.in);
boolean answer1 =(isSecurePassword( input.nextLine()));
System.out.println(answer1);
}
public static boolean isSecurePassword (String password){
int i;
for (i=0;i<password.length();i++){
if (i!=10)
{
return false;
}
boolean uppercase=false;
boolean lowercase=false;
boolean digit=false;
int counter;
for(counter=0;counter<password.length();counter++){
if (counter>='a'&& counter <='z'){
lowercase = true;
}
else if (counter>='A'&&counter <='Z'){
uppercase=true;
}
else if ( counter>=0&&counter<=9){
digit=true;
}
else {return false;
}
{return uppercase& lowercase& digit;
}
}
}
}
}
Member 13676546
13-Feb-18 17:16pm
View
Deleted
I tried to follow the instructions: this is what I came up with: when I compile it gives me errors , some of them syntax errors.. could u give me points which part do I need to work on thanx. by the way I cannot use scanner inside the method but I can read in the main method.
import java.util.Scanner;
public class PasswordValidator {
public static void main (String[] args){
Scanner input= new Scanner (System.in);
boolean answer1 =(isSecurePassword( input.nextLine()));
System.out.println(answer1);
}
public static boolean isSecurePassword (String password){
int i;
for (i=0;i<password.length();i++){
if (i!=10)
{
return false
}
boolean uppercase=false;
boolean lowercase=false;
boolean digit=false;
for(counter=0;counter<password.length;counter++){
if (counter>='a'&& counter <='z'){
lowercase = true;
}
else if {counter>='A'&&counter <='Z'){
uppercase==true;
}
else if ( counter>=0&&counter<=9){
digit=true;
}
else {return false;
}
retrun uppercase; lowercase;digit;
}
}
}
Member 13676546
13-Feb-18 13:13pm
View
thanks for the explanation . when I compile the first part which is check if it has 10 character it gives a message that it must return Boolean type .. so I still stuck in the fist part of the question..
Show More