3. Use a text editor to create a comma-delimited file of user IDs and passwords. Revise any one of the games you have created throughout this book so the user must first enter a correct ID and its associated password before playing. Save the program as GameWithPassword.java.
Note: Done accordingly. Please comment for any problem. Please Uprate. Thanks
Please add code to open your previous game when login is successful. I already highlighted that part,
Code:
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
public class GameWithPassword {
static int checkLoginDetails(String username,
String password) {
int status = 0; //status 0 means
username does not exist
try {
//opening
file
BufferedReader
br = new BufferedReader(new FileReader("loginDatabase.txt"));
String line =
null;
//reading line
by line
while ((line =
br.readLine()) != null) {
String[] values = line.split(",");//split
username and password
if (values[0].equals(username)) {//checking for
username
if
(values[1].equals(password)) {//checking for password
br.close();
return
1;//both are correct
} else {
status =
2; //username is correct but password is wrong
}
}
}
br.close();
} catch (IOException e) {
System.out.println("File does not exist.");
e.printStackTrace();
}
return status;
}
public static void main(String[] args) {
//creating instance of scanner
class
Scanner read = new
Scanner(System.in);
String username,password;
int result;
//reading username
System.out.print("Please give
username :");
username=read.nextLine();
//reading password
System.out.print("Please give
password :");
password=read.nextLine();
//Checking login details
result=checkLoginDetails(username,password);
//printing appropriate
message
if(result==0){
System.out.println("Username does not exist.");
}else if(result==2){
System.out.println("Password is not correct for username :
"+username);
}else{//login is successful
System.out.println("Success");
//ADD
CODE TO OPEN GAME
}
read.close();
}
}
Outputs:
3. Use a text editor to create a comma-delimited file of user IDs and passwords. Revise...
Language: C++ PLEASE INCLUDE SCREENSHOT OF OUTPUT In this assignment, you will consider the problem of organizing a collection of computer user-ids and passwords. Each time a user logs in to the system by entering his or her user-id and a secret password, the system must check the validity of this user-id and password to verify that this is a legitimate user. Because this validation must be done many times each day, it is necessary to structure this information in...
Create a python script to manage a user list that can be modified and saved to a text file. Input text file consisting of pairs of usernames and passwords, separated by a colon (:) without any spaces User choice: (‘n’-new user account, ‘e’-edit existing user account, ‘d’- delete existing user account, ‘l’- list user accounts, ‘q’-quit) List of user accounts, error messages when appropriate Output text file consisting of pairs of username and passwords, separated by a colon (:) without...
Using Python
INST-FS-IAD-PROD.INS LAB1 Lab: Create User Account 2. get-password() #promt the user and create password, check the password fits the requirement USE the EXACT file names! Create a user login system. Your code should do the following: 3, create-user_name() #use this function to create the user name 1.Create your user database called "UD.txt", this should be in CSV format 4, write-file() #user this function to save the user name and password into "UD.txt" Deliverables: Sample: the data you saved...
C#: Create a file that contains your favorite movie quote. Use a text editor such as Notepad and save the file as Quote.txt. Copy the file contents and paste them into a word-processing program such as Word. Save the file as Quote.doc. Write console application that displays the sizes of the two files as well as the ratio of their sizes to each other. To discover a file's size, you can create a System.IO.FileInfo object using a statement such as...
in C language 1. Create a data file called superheroes.dat using any text-based editor, and enter at least three records storing superheros' names and main superpower. Make sure that each field in the record is separated by a space. 2. Using the superheroes.dat file from problem 1, build another program that uses the fscanf() function for reading each record and printing field information to standard output until the end-of-file is reached. Include an error handling routine that notifies the user...
(In Linux) 1. Create a file to write to from your script and save it as “.txt”. 2. Write the following information to the file that you created in Step 1: Today's date Your full name Your student ID The name of your course What directory you are in File permissions of the file that you created that allow everyone to read, write, and execute The long list of files in your current directory, providing all items and their process...
Pig Latin Translator in Java The goal here is to read in the characters stored in a text file and create a second text file that contains the original text but with every word converted to “Pig-Latin.” The rules used by Pig Latin are as follows: • If a word begins with a vowel, just as "yay" to the end. For example, "out" is translated into "outyay". • If it begins with a consonant, then we take all consonants before...
You are to write a program (BookExceptionsDemo.java) that will
create and, using user input, populate an array of instances of the
class Book. The class Book is loaded in our Canvas files:
Book.java
The user will enter a number n (n must be > 0, trap the user
until they input a valid value for n), Your program will declare
and create an array of size n of instances of the class Book.
The user will be asked to enter...
Please solve. How do I create my own text file? Where do I save it so that it is recognized by python? Do I have to import it into my code? the prompt: Write a program that inputs a text file. The program should print the unique words in the file in alphabetical order. An example file along with the correct output is shown below: example.txt the quick brown fox jumps over the lazy dog Enter the input file name:...