diff --git a/Answers/40230112057/.gitignore b/Answers/40230112057/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/Answers/40230112057/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Answers/40230112057/.idea/misc.xml b/Answers/40230112057/.idea/misc.xml new file mode 100644 index 0000000..20f033c --- /dev/null +++ b/Answers/40230112057/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112057/.idea/modules.xml b/Answers/40230112057/.idea/modules.xml new file mode 100644 index 0000000..ca9c61b --- /dev/null +++ b/Answers/40230112057/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112057/.idea/vcs.xml b/Answers/40230112057/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/Answers/40230112057/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112057/.idea/workspace.xml b/Answers/40230112057/.idea/workspace.xml new file mode 100644 index 0000000..345ba15 --- /dev/null +++ b/Answers/40230112057/.idea/workspace.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1710346340454 + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112057/functt.iml b/Answers/40230112057/functt.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Answers/40230112057/functt.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112057/src/ap/Main.java b/Answers/40230112057/src/ap/Main.java new file mode 100644 index 0000000..f9c2d60 --- /dev/null +++ b/Answers/40230112057/src/ap/Main.java @@ -0,0 +1,70 @@ +package ap; +import java.util.Scanner; + +public class Main { + public static void main(String[] args){ + Scanner input=new Scanner(System.in); + int menu,index=0; + + resume[] obj; + obj=new resume[100]; + interests[] ooj=new interests[100]; + boolean done=true; + while(done){ + System.out.println("****************\nmenu:\n1.add a resume\n2.show list of resumes\n3.exit\n****************"); + menu=input.nextInt(); + switch (menu) { + case 1 -> { + obj[index] = new resume(); + String firstname; + String lastname; + System.out.println("enter your first name:"); + firstname = input.next(); + System.out.println("enter your last name:"); + lastname = input.next(); + obj[index].fullName(firstname, lastname); + String phone; + System.out.println("enter phone number:"); + phone = input.next(); + obj[index].phoneNumber(phone); + System.out.println("enter user id:"); + String id = input.next(); + obj[index].userId(id); + System.out.println("how many interests do you have?"); + int n = input.nextInt(); + while(n>10){ + System.out.println("the maximum number of interests is 10! enter another number: "); + n = input.nextInt(); + } + ooj[index] = new interests(n); + resume.getInterests(ooj[index], n); + index++; + } + case 2 -> { + if(index==0){ + System.out.println("there is no list"); + break; + } + System.out.println("##################"); + for (int i = 0; i < index; i++) + System.out.print((i + 1) + "." + "name:" + obj[i].name + "\n"); + System.out.println("##################"); + System.out.println("enter the number behind the name that you want to see the encrypted resume:"); + int m = input.nextInt(); + System.out.println("enter the shift for encryption:"); + int shift = input.nextInt(); + String text1 = resume.userFullInformation(obj[m - 1].name, obj[m - 1].phone, obj[m - 1].id, ooj[m - 1]); + String text2 = resume.informationEncoder(text1, shift); + System.out.println(text2); + System.out.println("do you want it decrypted?[y/n]"); + String bul = input.next(); + if (bul.equals("y") || bul.equals("Y")) { + String text3 = resume.informationDecoder(text2, shift); + System.out.println("\n"+text3); + } + } + case 3 -> done = false; + } + } + } +} diff --git a/Answers/40230112057/src/ap/interests.java b/Answers/40230112057/src/ap/interests.java new file mode 100644 index 0000000..227bd5e --- /dev/null +++ b/Answers/40230112057/src/ap/interests.java @@ -0,0 +1,22 @@ +package ap; +public class interests { + public int size=0; + public int index=0; + private String[] intrests; + public interests(int n){ + size=n; + intrests=new String[n]; + } + public String[] array(){ + return this.intrests; + } + public void add_intrests(String neww){ + this.intrests[index]=neww; + index++; + } + public String index_return(int n){ + return intrests[n]; + } + } + + diff --git a/Answers/40230112057/src/ap/resume.java b/Answers/40230112057/src/ap/resume.java new file mode 100644 index 0000000..62442a8 --- /dev/null +++ b/Answers/40230112057/src/ap/resume.java @@ -0,0 +1,91 @@ +package ap; +import java.util.Scanner; +public class resume { + public String name; + public String id; + public String phone; + + public void fullName(String firstName,String lastName){ + String First=firstName.toLowerCase(); + String Second=lastName.toLowerCase(); + char[] neww1=First.toCharArray(); + char[] neww2=Second.toCharArray(); + neww1[0]-=32; + neww2[0]-=32; + String akhari=new String(neww1); + String akharii=new String(neww2); + this.name=akhari+" "+akharii; + } + public void phoneNumber(String phone){ + Scanner input=new Scanner(System.in); + if(phone.length()==11 && phone.charAt(0)=='0' && phone.charAt(1)=='9' && phone.matches("[0-9]+")){ + this.phone=phone; + return; + } + + while(phone.length()!=10 || phone.charAt(0)!='9' || !phone.matches("[0-9]+")){ + System.out.println("Wrong entry. Try again."); + phone=input.next(); + if(phone.length()==11 && phone.charAt(0)=='0' && phone.charAt(1)=='9' && phone.matches("[0-9]+")){ + this.phone=phone; + return; + } + } + this.phone="0"+phone; + } + public void userId(String id){ + Scanner input=new Scanner(System.in); + while(4>=id.length() || 13<=id.length() || !id.matches("[0-9]+")){ + System.out.println("Wrong entry. Try again."); + id=input.next(); + } + + this.id=id; + } + public static String[] getInterests(interests obj,int n){ + Scanner input=new Scanner(System.in); + String temp; + for(int i=0;i96 && temp[i]<123) + temp[i]+=temp[i]+shift>122 ? shift-26 :shift; + else if (temp[i]>64 && temp[i]<91) + temp[i]+=temp[i]+shift>90 ? shift-26 : shift; + else if(temp[i]>=48 && temp[i]<=57) + temp[i]+=temp[i]+shift>57 ? shift-10 : shift; + + } + return new String(temp); + } + public static String informationDecoder(String information,int shift){ + char[] temp=information.toCharArray(); + for(int i=0;i96 && temp[i]<123) + temp[i]-=temp[i]-shift<97 ? shift-26 :shift; + else if (temp[i]>64 && temp[i]<91) + temp[i]-=temp[i]-shift<65 ? shift-26 : shift; + else if(temp[i]>=48 && temp[i]<=57) + temp[i]-=temp[i]-shift<48 ? shift-10 : shift; + } + return new String(temp); + } + +}