diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..299bc21
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+Function-Introduction
\ No newline at end of file
diff --git a/.idea/Functions-Introduction.iml b/.idea/Functions-Introduction.iml
new file mode 100644
index 0000000..1e317c5
--- /dev/null
+++ b/.idea/Functions-Introduction.iml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..cecb8d5
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..95e372b
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..00b1f81
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,205 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "lastFilter": {
+ "state": "OPEN",
+ "assignee": "Amirhoseinhmd83"
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "associatedIndex": 2
+}
+
+
+
+
+
+
+ {
+ "keyToString": {
+ "Application.Functions.executor": "Run",
+ "Application.Main.executor": "Run",
+ "Application.NameFormatter.executor": "Run",
+ "Downloaded.Files.Path.Enabled": "false",
+ "JUnit.Unnamed.executor": "Coverage",
+ "Repository.Attach.Annotations": "false",
+ "Repository.Attach.JavaDocs": "false",
+ "Repository.Attach.Sources": "false",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "git-widget-placeholder": "main",
+ "kotlin-language-version-configured": "true",
+ "last_directory_selection": "C:/Users/ASUS/Desktop/Functions-Introduction/Answers/40230212031/src",
+ "last_opened_file_path": "C:/Users/ASUS/Desktop/Functions-Introduction",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "project.structure.last.edited": "Modules",
+ "project.structure.proportion": "0.15",
+ "project.structure.side.proportion": "0.2",
+ "settings.editor.selected.configurable": "configurable.group.build",
+ "vue.rearranger.settings.migration": "true"
+ },
+ "keyToStringList": {
+ "com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
+ "PLAIN_TEXT"
+ ]
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1710356437818
+
+
+ 1710356437818
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ file://$APPLICATION_CONFIG_DIR$/scratches/scratch.java
+ 1
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230212031/.idea/.gitignore b/Answers/40230212031/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/Answers/40230212031/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/Answers/40230212031/.idea/.name b/Answers/40230212031/.idea/.name
new file mode 100644
index 0000000..002da1d
--- /dev/null
+++ b/Answers/40230212031/.idea/.name
@@ -0,0 +1 @@
+Main.java
\ No newline at end of file
diff --git a/Answers/40230212031/.idea/misc.xml b/Answers/40230212031/.idea/misc.xml
new file mode 100644
index 0000000..07115cd
--- /dev/null
+++ b/Answers/40230212031/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230212031/.idea/modules.xml b/Answers/40230212031/.idea/modules.xml
new file mode 100644
index 0000000..9a73810
--- /dev/null
+++ b/Answers/40230212031/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230212031/.idea/vcs.xml b/Answers/40230212031/.idea/vcs.xml
new file mode 100644
index 0000000..b2bdec2
--- /dev/null
+++ b/Answers/40230212031/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Answers/40230212031/src/org/example/Functions.java b/Answers/40230212031/src/org/example/Functions.java
new file mode 100644
index 0000000..f4eb9f6
--- /dev/null
+++ b/Answers/40230212031/src/org/example/Functions.java
@@ -0,0 +1,109 @@
+package org.example;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+
+public class Functions {
+ public String normalizingName(String firstName, String lastName) {
+ String normalizedFirstName = firstName.substring(0, 1).toUpperCase() + firstName.substring(1).toLowerCase();
+ //ابتدا حرف اول first name را با شروع اندیس از 0 و در نظر گرفتن پایان کلمه در اندیس 1 جدا کرده و به بزگ تبدیل میکنیم
+// و بعد از ان از اندیس یک به بعد همه ی حروف را به کوچک تبدیل میکنیم
+
+ String normalizedLastName = lastName.substring(0, 1).toUpperCase() + lastName.substring(1).toLowerCase();
+//مانند بالایی
+ return normalizedFirstName + " " + normalizedLastName;
+ }
+
+ //********************************************************************************************************************
+ public String formatPhoneNumber(String phoneNumber) {
+ if (checking(phoneNumber)) {
+ return "0" + phoneNumber;
+ } else {
+ return "Wrong entry. Try again.";
+ }
+ }
+
+ public boolean checking(String phone) {
+ return phone.startsWith("9") && phone.length() == 10;
+ }
+
+ //**********************************************************************************************************************
+ public String validateUserId(String userId) {
+
+ if (userId.length() >= 4 && userId.length() <= 13) {
+ // بررسی طول شناسه کاربری
+ return userId;
+ } else {
+ return "Invalid user ID. Please enter a user ID between 4 and 13 digits.";
+ }
+ }
+
+ //*************************************************************************************************************************
+ public String[] getInterests(String[] userInterests) {
+ String[] interests = new String[10];
+
+ for (int i = 0; i < Math.min(userInterests.length, 10); i++) { // حلقه برای کپی کردن علاقهمندیهای کاربر از آرایه ورودی به آرایه جدید
+ interests[i] = userInterests[i];
+ }
+
+ return interests;
+ }
+
+ //*************************************************************************************************************************************
+ public String userFullInformation(String fullName, String phoneNumber, String userID, String[] interests) {
+
+ StringBuilder userInfo = new StringBuilder();
+
+ userInfo.append("Full name: ").append(fullName).append("\n");
+
+
+ userInfo.append("Phone number: ").append(phoneNumber).append("\n");
+
+
+ userInfo.append("User ID: ").append(userID).append("\n");
+
+
+ userInfo.append("Interests: ").append(Arrays.toString(interests)).append("\n");
+
+
+ userInfo.append("\nOutput: Hello! My name is ").append(fullName).append(". My ID is ").append(userID)
+ .append(". Here are some of my interests:\n");
+ for (int i = 0; i < interests.length; i++) {
+ userInfo.append(i + 1).append(". ").append(interests[i]).append("\n");
+ }
+
+ userInfo.append("\nYou can reach me via my phone number ").append(phoneNumber).append(".");
+
+
+ return userInfo.toString();
+ }
+
+ //***************************************************************************************************
+ public static String informationEncoder(String information, int shift) {
+ StringBuilder encodedInformation = new StringBuilder();
+ // برای جمع اوری اطلاعات رمز گذاری شده
+ for (int i = 0; i < information.length(); i++) {// حلقه برای گردش از ابتدای رشته تا انتها
+ char ch = information.charAt(i);
+
+ if (Character.isLetter(ch)) {// بررسی اینکه آیا کاراکتر یک حرف است یا نه
+ char base;
+ if (ch>= 'A' && ch <= 'Z') { // تعیین پایه برای حروف بزرگ و کوچک است
+ base = 'A';
+ } else {
+ base = 'a';
+ }
+
+ char encodedChar = (char) (((ch - base + shift) % 26) + base);
+ encodedInformation.append(encodedChar);
+ } else {
+ encodedInformation.append(ch); // اگر کاراکتر غیر حروفی بود، بدون تغییر اضافه شود
+ }
+ }
+
+ return encodedInformation.toString();
+ }
+ public static String informationDecoder(String encodedInformation, int shift) {
+ return informationEncoder(encodedInformation, 26 - shift); // برای رمزگشایی از شیفت معکوس استفاده میشود
+ }
+}
\ No newline at end of file
diff --git a/Answers/40230212031/src/org/example/Main.java b/Answers/40230212031/src/org/example/Main.java
new file mode 100644
index 0000000..7b99f9a
--- /dev/null
+++ b/Answers/40230212031/src/org/example/Main.java
@@ -0,0 +1,133 @@
+package org.example;
+
+import java.util.Arrays;
+import java.util.Scanner;
+
+import static org.example.Functions.informationDecoder;
+import static org.example.Functions.informationEncoder;
+
+public class Main {
+ public static void main(String[] args) {
+ Scanner scanner = new Scanner(System.in);
+
+ System.out.print("Enter your first name: ");
+ String firstName = scanner.nextLine();
+
+ System.out.print("Enter your last name: ");
+ String lastName = scanner.nextLine();
+
+ Functions functions = new Functions();
+ String normalizedName = functions.normalizingName(firstName, lastName);
+
+ System.out.println("Normalized name: " + normalizedName);
+//////////////////////////////////////////////////////////////////////
+
+ System.out.print("Enter phone number: ");
+ String phone = scanner.nextLine();
+
+ while (!functions.checking(phone)) {
+ //اگر شماره وارد شده توسط کاربر صحیح نبود
+ System.out.println("Error . Try again.");
+ System.out.print("Enter phone number: ");
+ phone = scanner.nextLine();
+ //دریافت مجدد شماره توسط کاربر
+ }
+
+ String formattedPhone = functions.formatPhoneNumber(phone);
+ //در اینجا شماره قطغا درسته و به کاربر نمایش داده میشود
+ System.out.println("Your phone number: " + formattedPhone);
+
+ /////////////////////////////////////////////////////////////////////////
+ String userId = "";
+ while (true) {
+ System.out.print("Enter user ID: ");
+ userId = scanner.nextLine();
+ String validatedUserId = functions.validateUserId(userId);
+ if (!validatedUserId.startsWith("Invalid")) {
+ System.out.println("Validated user ID: " + validatedUserId);
+ break;
+ } else {
+ System.out.println(validatedUserId);
+ }
+ }
+ ////////////////////////////////////////////////////////////////////////////
+
+
+ scanner = new Scanner(System.in);
+
+ System.out.println("Please enter your interests (maximum 10 interests, enter 'done' to finish):");
+
+ String[] userInterests = new String[10];
+
+ int i = 0;
+
+ String input;
+ // تعریف متغیر برای ذخیره ورودی کاربر
+
+ while (i < userInterests.length) { // حلقه برای دریافت حداکثر 10 علاقهمندی از کاربر
+
+ System.out.print("Input: ");
+
+ input = scanner.nextLine().trim();
+ // حذف فاصلههای اضافی از ابتدا و انتهای رشته
+
+ if (input.equals("done")) { // اگر ورودی "done" باشد حلقه متوقف میشود
+ break;
+ }
+
+ userInterests[i++] = input;
+ // ذخیره ورودی کاربر در آرایه علاقهمندیها و افزایش شمارنده
+ }
+
+ functions = new Functions();
+
+ String[] interests = functions.getInterests(userInterests);
+// فراخوانی متد getInterests با استفاده از آرایه علاقهمندیهای کاربر و ذخیره نتیجه در آرایه جدید
+ System.out.print("Output: ");
+
+ for (String interest : interests) {
+ // حلقه برای نمایش علاقهمندیهای دریافت شده به کاربر
+
+ if (interest != null) { //اگر مقدار غیر null باشد نمایش آن
+ System.out.print(interest + "-");
+ }
+ }
+ ///////////////////////////////////////////////////////////////////////////////////////
+ String information = normalizedName + ", " + formattedPhone + ", " + userId + ", " + Arrays.toString(interests);
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+ String encodedInformation = null;
+ while (true) {
+ System.out.print("Do you want to encode, decode your information, or exit? (encode/decode/exit): ");
+ String choice = scanner.nextLine();
+
+ switch (choice.toLowerCase()) {
+ case "encode":
+ System.out.print("Enter shift value: ");
+ int shiftEncode = scanner.nextInt();
+ scanner.nextLine();
+ // خالی کردن خط بعدی
+ encodedInformation = informationEncoder(information, shiftEncode);
+ System.out.println("Encoded information: " + encodedInformation);
+ break;
+ case "decode":
+ if (encodedInformation == null) {
+ // اگر کاربر کد مورد نظرش را وارد نکرده عبارت زیر را چاپ می کند
+ System.out.println("No encoded information available. Please encode the information first.");
+ continue; // برگشت به ابتدای حلقه برای ورود مجدد دستور
+ }
+ System.out.print("Enter shift value: ");
+ int shiftDecode = scanner.nextInt();
+ scanner.nextLine();
+
+ String decodedInformation = informationDecoder(encodedInformation, shiftDecode);
+ System.out.println("Decoded information: " + decodedInformation);
+ break;
+ case "exit":
+ System.out.println("Exiting program...");
+ return; // خروج از حلقه و پایان برنامه
+ default:
+ System.out.println("Invalid choice!");
+ }
+ }
+ }
+}
\ No newline at end of file