From 7ccd285b45bc0bedf7bdf56140ad1d414a4b7483 Mon Sep 17 00:00:00 2001 From: "Amir.Homa" Date: Mon, 18 Mar 2024 10:21:37 +0330 Subject: [PATCH 1/8] add fullname function --- {Answers => 40230112134}/How to send.txt | 0 40230112134/README.md | 99 +++++++++++++++++++ 40230112134/untitled/.gitignore | 38 +++++++ 40230112134/untitled/.idea/encodings.xml | 7 ++ 40230112134/untitled/.idea/misc.xml | 14 +++ 40230112134/untitled/.idea/vcs.xml | 6 ++ 40230112134/untitled/.idea/workspace.xml | 82 +++++++++++++++ 40230112134/untitled/pom.xml | 17 ++++ .../src/main/java/org/example/Homa.java | 65 ++++++++++++ 9 files changed, 328 insertions(+) rename {Answers => 40230112134}/How to send.txt (100%) create mode 100644 40230112134/README.md create mode 100644 40230112134/untitled/.gitignore create mode 100644 40230112134/untitled/.idea/encodings.xml create mode 100644 40230112134/untitled/.idea/misc.xml create mode 100644 40230112134/untitled/.idea/vcs.xml create mode 100644 40230112134/untitled/.idea/workspace.xml create mode 100644 40230112134/untitled/pom.xml create mode 100644 40230112134/untitled/src/main/java/org/example/Homa.java diff --git a/Answers/How to send.txt b/40230112134/How to send.txt similarity index 100% rename from Answers/How to send.txt rename to 40230112134/How to send.txt diff --git a/40230112134/README.md b/40230112134/README.md new file mode 100644 index 0000000..e57bd50 --- /dev/null +++ b/40230112134/README.md @@ -0,0 +1,99 @@ +# Introduction to Functions + +This time, we want to delve into creating different types of functions and using them in Java. Your task is to implement some functions and use them correctly to reach the program's goal. Let's start with the program. + +## What is the project about? + +In this assignment, we want you to create a simple resume maker. There are some functions to collect the user's information and, at the end, show the user's information. + +## Functions + +Let's talk about functions. + +### fullName(firstName, lastName) + +This function takes two parameters: the first name and last name of the user and returns their full name. This function should correct the format of the user's first name and last name. For example: + +```plaintext +First name: ArYAn +Last name: nourBAKhsh + +Full name: Aryan Nourbakhsh +``` + +### phoneNumber(phone) + +This function receives a phone number, and if the phone number starts with a 9 and is 10 digits long, it returns the phone number and adds a 0 at the beginning. Note: If the entered number is incorrect, the program shouldn't stop, and it should prompt the user to enter another phone number. + +```plaintext +Phone: 9123456789 +Output: 09123456789 + +Phone: 912345 +Output: Wrong entry. Try again. +``` + +### userId(id) + +This function is responsible for student IDs. It checks the format, and if correct, it returns it. If the format is incorrect, it prompts the user for another entry. The userID should be between 4 to 13 digits. + +```plaintext +ID: 40030111111 +Output: 40030111111 +``` + +### getInterests(interests) + +This function gives users interests and returns an array of interests. The maximum number of interests is 10. + +```plaintext +Input: swimming +Input: gym +Input: video games + +Output: {"swimming", "gym", "video games"} +``` + +### userFullInformation(fullName, phoneNumber, userID, interests) + +This function gets user data and returns the full information of the user. + +```plaintext +Full name: Aryan Nourbakhsh +Phone number: 09123456789 +User ID: 40030111111 +Interests: {"swimming", "gym", "video games"} + +Output: Hello! My name is Aryan Nourbakhsh. My ID is 40030111111. Here are some of my interests: +1. Swimming +2. Gym +3. Video games + +You can reach me via my phone number 09123456789. +``` + +### informationEncoder(information, shift) + +In this function, we get user information and use the Caesar algorithm to encrypt the information, returning the result. You can read about the Caesar Cipher [here](https://en.wikipedia.org/wiki/Caesar_cipher). Here is a sample of input and output: + +```plaintext +Information: Hello, my name is Aryanoor. I am learning Java. +Shift: 3 + +Output: Khoor, pb qdph lv Dubdqrru. L dp ohduqlqj Mdyd. +``` + +### informationDecoder(information, shift) + +This function receives an encoded text and decodes it back to readable text, providing the reversed form of the last function. + +```plaintext +Information: Fvb mvbuk tl jvyyljasf. +Shift: 7 + +Output: You found me correctly. +``` + +Note that initially, you should encode the user information, and the user may choose whether to see the encoded details or not. Create a main function to get user information from input and pass them to each function. + +Good luck! \ No newline at end of file diff --git a/40230112134/untitled/.gitignore b/40230112134/untitled/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/40230112134/untitled/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/40230112134/untitled/.idea/encodings.xml b/40230112134/untitled/.idea/encodings.xml new file mode 100644 index 0000000..aa00ffa --- /dev/null +++ b/40230112134/untitled/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/40230112134/untitled/.idea/misc.xml b/40230112134/untitled/.idea/misc.xml new file mode 100644 index 0000000..82dbec8 --- /dev/null +++ b/40230112134/untitled/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/40230112134/untitled/.idea/vcs.xml b/40230112134/untitled/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/40230112134/untitled/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/40230112134/untitled/.idea/workspace.xml b/40230112134/untitled/.idea/workspace.xml new file mode 100644 index 0000000..2d08d4f --- /dev/null +++ b/40230112134/untitled/.idea/workspace.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + { + "associatedIndex": 7 +} + + + + + + + + + + + + + + + + + + + + + 1710606526420 + + + + + + \ No newline at end of file diff --git a/40230112134/untitled/pom.xml b/40230112134/untitled/pom.xml new file mode 100644 index 0000000..d69c9eb --- /dev/null +++ b/40230112134/untitled/pom.xml @@ -0,0 +1,17 @@ + + + 4.0.0 + + org.example + untitled + 1.0-SNAPSHOT + + + 17 + 17 + UTF-8 + + + \ No newline at end of file diff --git a/40230112134/untitled/src/main/java/org/example/Homa.java b/40230112134/untitled/src/main/java/org/example/Homa.java new file mode 100644 index 0000000..5794a54 --- /dev/null +++ b/40230112134/untitled/src/main/java/org/example/Homa.java @@ -0,0 +1,65 @@ +package org.example; + +import java.util.Scanner; + +public class Homa { + public static void main(String[] Amir) + { + Scanner name = new Scanner(System.in); + System.out.println("enter your firstname : "); + String first = name.nextLine(); + System.out.println("enter your lastname : "); + String last = name.nextLine(); + String fullname = fullName(first,last); + + + } + + static String fullName(String firstname,String lastname) + { + char[] F = firstname.toCharArray(); + char[] L = lastname.toCharArray(); + if (F[0]>96 && F[0]<123) + { + F[0] = (char) (F[0]-32); + } + if (L[0]>96 && L[0]<123) + { + L[0] = (char) (L[0]-32); + } + for (int i = 1; i < firstname.length(); i++) + { + if (F[i]>96 && F[i]<123) + { + } + else + { + F[i] = (char) (F[i]+32); + } + } + for (int i = 1; i < lastname.length(); i++) + { + if (L[i]>96 && L[i]<123) + { + } + else + { + L[i] = (char) (L[i]+32); + } + } + char[] Full = new char[(firstname.length() + lastname.length() + 1)]; + for (int i = 0; i < firstname.length(); i++) + { + Full[i]=F[i]; + } + Full[firstname.length()]=' '; + int j=0; + for (int i = firstname.length()+1 ; i < firstname.length() + lastname.length() + 1 ; i++) + { + Full[i]=L[j]; + j++; + } + String FULLNAME = new String(Full); + return FULLNAME; + } +} \ No newline at end of file From 6a42f9e624013b7b6e95e6a70bc7582fae10f4aa Mon Sep 17 00:00:00 2001 From: "Amir.Homa" Date: Mon, 18 Mar 2024 11:24:17 +0330 Subject: [PATCH 2/8] add phonenumber and id function --- 40230112134/untitled/.idea/workspace.xml | 19 ++++-- .../src/main/java/org/example/Homa.java | 66 +++++++++++++++++-- 2 files changed, 75 insertions(+), 10 deletions(-) diff --git a/40230112134/untitled/.idea/workspace.xml b/40230112134/untitled/.idea/workspace.xml index 2d08d4f..547cf38 100644 --- a/40230112134/untitled/.idea/workspace.xml +++ b/40230112134/untitled/.idea/workspace.xml @@ -5,11 +5,8 @@ - - - - - + + diff --git a/40230112134/untitled/src/main/java/org/example/Homa.java b/40230112134/untitled/src/main/java/org/example/Homa.java index 255db62..f8b4252 100644 --- a/40230112134/untitled/src/main/java/org/example/Homa.java +++ b/40230112134/untitled/src/main/java/org/example/Homa.java @@ -1,5 +1,6 @@ package org.example; +import java.util.Objects; import java.util.Scanner; public class Homa { @@ -17,8 +18,30 @@ public static void main(String[] Amir) System.out.print("enter your userid : "); String user = name.nextLine(); String ID = UserId(user); + System.out.print("enter your interests : "); + String[] Interest = getInterests(); + + } + static String[] getInterests() + { + Scanner input = new Scanner(System.in); + String[] List = new String[10]; + int i = 0; + boolean flag = false; + while (flag == false) + { + List[i] = input.nextLine(); + System.out.println("if you done enter (0)"); + if (Objects.equals(List[i], "0")) + { + flag = true; + break; + } + i++; + } + return List; } static String UserId (String id) { From 6f57927de68fd31b2e1c80f663c221097ed6dd07 Mon Sep 17 00:00:00 2001 From: "Amir.Homa" Date: Mon, 18 Mar 2024 15:50:20 +0330 Subject: [PATCH 5/8] add userinformation method --- 40230112134/untitled/.idea/workspace.xml | 48 +++++++++++-------- .../src/main/java/org/example/Homa.java | 28 +++++++++-- 2 files changed, 50 insertions(+), 26 deletions(-) diff --git a/40230112134/untitled/.idea/workspace.xml b/40230112134/untitled/.idea/workspace.xml index 5df46e2..583aaa6 100644 --- a/40230112134/untitled/.idea/workspace.xml +++ b/40230112134/untitled/.idea/workspace.xml @@ -27,21 +27,21 @@