[text] project

Viewer

  1. package JavaApplication6.src.javaapplication6;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class JavaApplication6 {
  6.        
  7.         public static String menu() {
  8.                 Scanner scan = new Scanner(System.in);
  9.                 System.out.println("Welcome to MarmaraBank Online System, please login to continue.");
  10.                 System.out.println("Login or Register (L/R): ");
  11.                 String st = scan.nextLine();
  12.                 st = st.toLowerCase();
  13.                 return st;
  14.         }
  15.        
  16.         public static String mail(String name, String sname, int byear) {
  17.                 String newname = name.toLowerCase();
  18.                 String newsname = sname.toLowerCase();
  19.                
  20.                 String mail = newname + "." + newsname + byear + "@account.com";
  21.                 return mail;
  22.         }
  23.        
  24.         public static String pw(String name, String sname, int byear) {
  25.                 double num = (double)(Math.random() * 101);
  26.                  
  27.                 String pw =  sname + "#" + Math.round(num) + "@" + name;
  28.                 return pw;
  29.         }
  30.        
  31.         public static void main(String[] args) {
  32.                 String st = "";
  33.                 Scanner scan1 = new Scanner(System.in);
  34.                 String r = "r";
  35.                 String l = "l";             
  36.                 st = menu();
  37.         String mail = null;
  38.         String pw = null;
  39.                 
  40.                 if (st.equals(r)) {
  41.                         System.out.println("You are now creating your online back account...");
  42.                         System.out.println("Enter your name: ");
  43.                         String name = scan1.nextLine();
  44.                         System.out.println("Enter your surname: ");
  45.                         String sname = scan1.nextLine();
  46.                         System.out.println("Enter your birthyear: ");
  47.                         int byear = scan1.nextInt();
  48.                        
  49.                         if (2021 - byear < 18) {
  50.                                 System.out.println("You need to be above 18 to create a bank account.");
  51.                         }
  52.                         else {
  53.                                 mail = mail(name, sname, byear);
  54.                                 pw = pw(name, sname, byear);
  55.                                 System.out.println("Your mail is: " + mail);
  56.                                 System.out.println("Your password is: " + pw);
  57.                                 System.out.println("You are now being directed to login page...");
  58.                                
  59.                                 while (true) {
  60.                                         System.out.println("Enter your mail: ");
  61.                                         scan1.nextLine(); // yeni satıra geçmeyi sağlıyor galiba, bunu koymadığımda birinci inputu giremeden 2.yi istiyor
  62.                                         String inp_mail = scan1.nextLine();
  63.                                         System.out.println("Enter your password: ");
  64.                                         String inp_pw = scan1.nextLine();
  65.                                         System.out.println(inp_mail);
  66.                                         System.out.println(inp_pw);
  67.                                        
  68.                                         if ((mail.equals(inp_mail)) && (pw.equals(inp_pw))) {
  69.                                                 System.out.println("Login successful, leading you to online banking website...");
  70.                                                 break;
  71.                                         }
  72.                                         else {
  73.                                                 System.out.println("Wrong mail or password");
  74.                                                         }
  75.                                                 }
  76.                                
  77.                                 System.out.println("Choose what you want to do:");
  78.                                 System.out.println("Simple Interest Calculator (1) ");
  79.                                 int num2 = scan1.nextInt();
  80.                                
  81.                                 if (num2 == 1) {
  82.                                         System.out.println("Enter the amount of money: ");
  83.                                         int money = scan1.nextInt();
  84.                                         System.out.println("Enter the rate of interest (percentage): ");
  85.                                         int interest = scan1.nextInt();
  86.                                         System.out.println("Enter the time period (years): ");
  87.                                         int period = scan1.nextInt();
  88.                                        
  89.                                         for (int i = 1; i <= period; i++) {
  90.                                                 int intr_money = money + (money*interest/100*i);
  91.                                                 System.out.println("Your money in " + i + " years is: " + intr_money);
  92.                                         }
  93.                                        
  94.                                        
  95.                                 }
  96.                                
  97.                                
  98.                                         }
  99.                      }
  100.                      else {
  101.                              System.out.println("You need to register first.");
  102.                           }
  103.  
  104.         }
  105. }
  106.     
  107.  
  108.  

Editor

You can edit this paste and save as new:


File Description
  • project
  • Paste Code
  • 30 Nov-2021
  • 3.24 Kb
You can Share it: