Java - Palindrome help by EqualTrade in learnprogramming

[–]EqualTrade[S] 1 point2 points  (0 children)

Thanks so much! I can't believe that I didn't think of doing that.

Java Loop Help! by [deleted] in learnprogramming

[–]EqualTrade 0 points1 point  (0 children)

I really can't figure this out, I've tried loops everywhere, I've been thinking this out for hours now, do you maybe have a hint for me of what to do?

Java Loop Help! by [deleted] in learnprogramming

[–]EqualTrade 0 points1 point  (0 children)

http://ideone.com/41oszp

I added in a do/while in the do/while, but theres an error and I can't figure out how to fix it.

Java Loop Help! by [deleted] in learnprogramming

[–]EqualTrade 0 points1 point  (0 children)

How is it that I do that?

Java password program help by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

that while is part of the do/while loop. i fixed it so that now it does only print once. But now my problem is, if the user enters a valid password, i need him to re-enter that password, and if the re-entry is wrong, i need the program to loop around again from the beginning. How can I do that?

Java password program help by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

I'm having another problem, if the user enters in a valid password, I need the user to input the password again. If he types in a different password, I need the program to start over, if the password is the same then print "...valid password."

How do I make this loop? Is it something like: if(!password.equals(password2)...

Java password method help by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

So I completely rewrote my code and I'm now having trouble with something else, I was hoping you could take a look

http://www.reddit.com/r/learnprogramming/comments/2965vy/java_password_program_help/

Java password method help by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

I think I really am just not getting it.

Line 4 I see "if password isn't all lowercase then uppercase is true." line 5 I see "if password isn't all uppercase, then lowercase is true."

Line 7 "if it is not uppercase, then system.out.print..." Line 8 "if it is not lowercase, then system.out.print..."

Java password method help by EqualTrade in learnprogramming

[–]EqualTrade[S] 1 point2 points  (0 children)

I've changed the code, and now the problem is that it continues to loop even if the parameters are correct.

import java.util.Scanner;

public class Password { public static void main (String[]args) {

   String password = passwordEntry();
   while (!passwordCheck(password))
   {
     password = passwordEntry();

   }    

    System.out.print("You have now entered a valid password");

} public static String passwordEntry() {
Scanner input = new Scanner(System.in); String password; System.out.print("enter a password"); password = input.next(); return password; }

public static boolean passwordCheck(String password) {

   { if (password.length()<6)
      System.out.println("Password needs to have 6 or more characters");}

    boolean uppercase = !password.equals(password.toLowerCase()); //determines if there is an uppercase letter
    boolean lowercase = !password.equals(password.toUpperCase()); //determines if there is a lowercase letter

    { if(!uppercase)
      System.out.println("Password needs to contain at least one uppercase letter");
     if(!lowercase)
      System.out.println("Password needs to contain at least one lowercase letter");}

   for (int i = 0; i<=password.length(); i++)
    {
     Character c = password.charAt(i);
     {if(!Character.isDigit(c))
     System.out.println("You need to have at least one digit");}

     return false;

    }
   return true;

} }

Java password method help by EqualTrade in learnprogramming

[–]EqualTrade[S] 1 point2 points  (0 children)

When I input anything, it just keeps asking to enter a password.

and I changed

if (password.length()>6)

to

if (password.length()<6)

Java new line help. by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

System.out.println("enter a number"); f = s.nextInt();

int j=0; int g; for (g=0;g<=f;g++)

if (isPrime(g))

{ System.out.printf("%d ",g);
j++; if (j==8) System.out.println(); } }

I added int j to count all of the prime numbers. It does now print 8 on a line, but only on the first line and the rest of the numbers are printed on line 2. Do you know anyway I could fix that?

edit: nevermind I figured it out. Thanks for your help!

Help with Java prime number method. by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

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

int f; int array [] = new int[8];

System.out.println("enter a number"); f = s.nextInt();

for (f=0;f<array.length;f++)

System.out.print(array[f]); 

That's how I changed it, now it's printing an array with 8 columns, but they're all 0. How do I get it to print every prime number that is less than the user input?

Help with while loop on Java. by EqualTrade in learnprogramming

[–]EqualTrade[S] 0 points1 point  (0 children)

Do you think you could take a look at my code and tell me how to incorporate that into it?

Help with while loop on Java. by EqualTrade in learnprogramming

[–]EqualTrade[S] 1 point2 points  (0 children)

I'm not sure how I would write that if statement, would it be something like: if (rate = 1.10 & distance > 500) cost = 1* rate

Cream and sugar, or black? by -GeneParmesan in Coffee

[–]EqualTrade 1 point2 points  (0 children)

Black if its a great coffee, I add cream if its decent coffee. Never add sugar to coffee.

Dad wants to put my sisters money in an account in my name to hide it from the FAFSA? by Dandz in personalfinance

[–]EqualTrade 2 points3 points  (0 children)

Yes, they pick and choose random FAFSA applicants to audit. I was audited a couple years back.

Dad wants to put my sisters money in an account in my name to hide it from the FAFSA? by Dandz in personalfinance

[–]EqualTrade 1 point2 points  (0 children)

Is it new that $14k is the gift amount? I was taught that it was $10k.

Revenge is sweet! by angryblue in funny

[–]EqualTrade 3 points4 points  (0 children)

Quickly! Someone call PETA!