Advertisement
Guest User

Stackoverflow

a guest
Sep 5th, 2018
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. import java.util.Scanner;
  2. import com.rethinkdb.RethinkDB;
  3. import com.rethinkdb.gen.exc.ReqlError;
  4. import com.rethinkdb.gen.exc.ReqlQueryLogicError;
  5. import com.rethinkdb.model.MapObject;
  6. import com.rethinkdb.net.Connection;
  7. import static org.ap.Database.r;
  8.  
  9. public class UserInput {
  10. public static Double[] grabInput(){
  11. Connection conn = r.connection().hostname("Private").port(28015).connect();
  12. Scanner scan = new Scanner(System.in);
  13.  
  14. //Decide what the scanner will be looking for
  15. System.out.print("What action will you be completing?: ");
  16. String action = scan.nextLine();
  17.  
  18. //Scans For Action Requests
  19. if (action.equals("Login")){
  20. //Login Action
  21. System.out.print("Username: ");
  22. String username = scan.nextLine();
  23. System.out.print("Password: ");
  24. String password = scan.nextLine();
  25.  
  26. //Login Validation
  27.  
  28. if (r.db("APSCI").table("BankAccounts").filter(row ->
  29. row.g("username").eq(username).and(row.g("password").eq(password))).coerceTo("BOOL").run(conn)){
  30. System.out.print("Welcome /n (username)");
  31. }
  32. else {
  33. System.out.print("No User Was Found!");
  34. }
  35. }
  36.  
  37. if (action.equals("Numbers")){
  38. //Decide the number of numbers to be used in the array
  39. System.out.print("Enter how many numbers you will input: ");
  40. Integer numOfNumbers = Integer.parseInt(scan.nextLine());
  41.  
  42. //Create a string array to store the numbers that will be used
  43. Double arrayOfNumbers[] = new Double[numOfNumbers];
  44. for (int i = 0; i < arrayOfNumbers.length; i++) {
  45. System.out.print("Enter the number " + (i+1) + " : ");
  46. arrayOfNumbers[i] = Double.parseDouble(scan.nextLine());
  47. }
  48.  
  49. //Now show your numbers
  50. System.out.print("My numbers : ");
  51. System.out.print(arrayOfNumbers[0]);
  52. for (int i = 1;i < arrayOfNumbers.length;i++) {
  53. System.out.print(" , " + arrayOfNumbers[i]);
  54. }
  55. System.out.println();
  56.  
  57. return arrayOfNumbers;
  58.  
  59.  
  60. }
  61. return null;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement