lundi 1 février 2016

When entered right username it directs to else [duplicate]

This question already has an answer here:

I was wondering how come when I enter my username correctly in the console when prompted that it still directs me into the else code or in other words. Says that i have entered the wrong password when correct it's supposed to say welcome.

package com.racecar484.user;

import java.util.Scanner;

class Application extends Game {

    public void calculator1(String args, int num) {
        int numb2, numb3, numb4;

    }

    public static void main(String args[]) {
        int Hotel = 50;
        int day = 1;
        int night = 12;
        int CarRent = 230;
        int Foodservice = 25;
        int cab = 300;
        String name = "Hernandez";
        String $ = "$";
        String Username = null;
        int cash = 500;
        boolean roomvacancy = true;
        boolean roomnotvacant = false;
        String password = null;
        String word;
        int num;
        Scanner in = new Scanner(System.in);
        if (Hotel <= 51 && day < 3) {
            System.out.println("Hello, and welcome to the CrunchGames Login panel.");
            System.out.println("Please enter your username and password down below!");
            Username = in.nextLine();
            System.out.println("Please enter your password.");
            password = in.nextLine();
            System.out.println("Logged in securely.");
            System.out.println("Please press any " + "ENTER" + " to resume.");
            String anykey = in.nextLine();

            System.out.println("System check....");
            System.out.println("System up to date.");
            System.out.println("Initiation sequence.");
            System.out.println("Welcome back to the CrunchGames application " + Username + ".");
            String[] myname = { "Alpha", "Bravo", "Charlie", "Delta" };
            {

            }
        } else {
            System.out.println("System is not up to date or");
            System.out.println(" does not support the version of this app.");
            System.out.println("Please update to a newer O.S or update the Application.");
        }

        System.out.println("Please enter your username and password one more ");
        System.out.println("time to verify that you are indeed the account user");
        String UsernameVerification = in.nextLine();
        if (UsernameVerification != Username) {
            System.out.println("Sorry that is the wrong user name, please try logging in again.");
            System.out.println("Enter your username.");
            String Username2 = in.nextLine();
        } else {
            System.out.println("Enter your password");
            password = in.nextLine();
        }
        System.out.println("Please Verify your password in order to continue.");
        String password2 = in.nextLine();
        if (password2 != password) {
            System.out.println("Password is incorrect, please try again.");
            password = in.nextLine();
            if (password2 == password) {
                System.out.println("Welcome to the CrunchGames Application!");
                System.out.println("Would you like to set up your profile?");
                String profile = in.nextLine();
                String yes = "yes";
                String no = "no";
                if (profile == yes) {
                    System.out.println("404 Page not found, sorry.");
                }
                if (profile == no) {
                    System.out.println("Ok, again welcome!");
                }
            }
        }

    }

    public void test(String[] args) {
        boolean a = true;
        String b = "Hello";
        if (a == true) {
            System.out.println(b);
        }
    }

    // Array
    public void arrays(String[] args, int[] arg) {

        int[] Arr = new int[34];
        Arr[2] = 42;
        System.out.println(Arr[2]);

    }

    {
    }
}

Aucun commentaire:

Enregistrer un commentaire