From f78e0340953d9f9d3d65fbe6312410b059bf1b3b Mon Sep 17 00:00:00 2001 From: touka6 Date: Sun, 17 Mar 2024 21:25:03 +0330 Subject: [PATCH 1/4] 5 files added --- Answers/40230112113/FullName.java | 28 +++++ Answers/40230112113/UserFullinformation.java | 110 +++++++++++++++++++ Answers/40230112113/getinterests.java | 44 ++++++++ Answers/40230112113/phoneNumber.java | 30 +++++ Answers/40230112113/userid.java | 21 ++++ 5 files changed, 233 insertions(+) create mode 100644 Answers/40230112113/FullName.java create mode 100644 Answers/40230112113/UserFullinformation.java create mode 100644 Answers/40230112113/getinterests.java create mode 100644 Answers/40230112113/phoneNumber.java create mode 100644 Answers/40230112113/userid.java diff --git a/Answers/40230112113/FullName.java b/Answers/40230112113/FullName.java new file mode 100644 index 0000000..5fee680 --- /dev/null +++ b/Answers/40230112113/FullName.java @@ -0,0 +1,28 @@ +package t2; + +import java.util.Scanner; + +public class FullName +{ + public static void main(String[] args) + { + Scanner sc=new Scanner(System.in); + String Firstname=sc.nextLine(); + String Lastname=sc.nextLine(); + sc.close(); + ; + System.out.println(change(Firstname, Lastname)); + } + public static String change(String s1 , String s2) + { + s1=s1.toLowerCase(); + s2=s2.toLowerCase(); + + s1 = s1.substring(0, 1).toUpperCase() + s1.substring(1); + s2 = s2.substring(0, 1).toUpperCase() + s2.substring(1); + + String s3=s1+" "+s2; + + return s3; + } +} diff --git a/Answers/40230112113/UserFullinformation.java b/Answers/40230112113/UserFullinformation.java new file mode 100644 index 0000000..7d7f4ff --- /dev/null +++ b/Answers/40230112113/UserFullinformation.java @@ -0,0 +1,110 @@ +package t2; + +import java.util.Scanner; + +public class UserFullinformation +{ + public static void main(String[] args) + { + Scanner sc=new Scanner(System.in); + + System.out.println("Please enter your name"); + String Firstname=sc.nextLine(); + String Lastname=sc.nextLine(); + + System.out.println("Please enter your phone number"); + String num=search(); + + System.out.println("Please enter your student ID"); + String Id=seeifright(); + + System.out.println("Please write some of your interests"); + Scanner scan = new Scanner(System.in); + String[] list = new String[10]; + int a=1; + String interests; + for (int i=0;i<10;i++) + { + System.out.println("write your word"); + interests = sc.nextLine(); + + list[i]=interests; + + System.out.println("do you want to stop writing? (enter 0 to stop and 1 to continue)"); + a=scan.nextInt(); + if (a==0) + break; + else + continue; + } + + //printing process + System.out.print("Hello! My name is " + change(Firstname, Lastname) + "."); + System.out.print("My ID is " + Id + ". Here are some of my interests:"); + printit(list); + System.out.println("\n You can reach me via my phone number " + num + "."); + } + public static String change(String s1 , String s2) + { + s1=s1.toLowerCase(); + s2=s2.toLowerCase(); + + s1 = s1.substring(0, 1).toUpperCase() + s1.substring(1); + s2 = s2.substring(0, 1).toUpperCase() + s2.substring(1); + + String s3=s1+" "+s2; + + return s3; + } + public static String search() + { + Scanner sc = new Scanner(System.in); + String num=sc.nextLine(); + + if ((num.length()==11)&&((num.charAt(0)=='0')&&(num.charAt(1)=='9'))) + { + return num; + } + else if ((num.length()==10)&&(num.charAt(0)=='9')) + { + num=0+num; + } + else + { + System.out.println("Wrong entry. Try again."); + num=search(); + } + return num; + } + public static String seeifright() + { + Scanner sc = new Scanner(System.in); + String Id=sc.nextLine(); + + if ((Id.length()>=15)||(Id.length()<=2)) + { + System.out.println("wrong student ID. please try again."); + Id=seeifright(); + } + return Id; + } + public static void printit(String[] list) + { + boolean checking=true; + System.out.print("{"); + for (int i=0;i<10;i++) + { + if(checking!=true) + System.out.print(","); + if(list[i]==null) + { + System.out.print("}"); + break; + } + System.out.print("\""+list[i]+"\""); + checking=false; + if (list[i+1]==null) + checking=true; + } + } +} diff --git a/Answers/40230112113/getinterests.java b/Answers/40230112113/getinterests.java new file mode 100644 index 0000000..bbfbbff --- /dev/null +++ b/Answers/40230112113/getinterests.java @@ -0,0 +1,44 @@ +package t2; + +import java.util.Scanner; + +public class getinterests +{ + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + Scanner scan = new Scanner(System.in); + String[] list = new String[10]; + int a=1; + for (int i=0;i<10;i++) + { + System.out.println("write your word"); + String interests = sc.nextLine(); + + list[i]=interests; + + System.out.println("do you want to stop writing? (enter 0 to stop and 1 to continue)"); + a=scan.nextInt(); + if (a==0) + break; + else + continue; + } + boolean checking=true; + System.out.print("{"); + for (int i=0;i<10;i++) + { + if(checking!=true) + System.out.print(","); + if(list[i]==null) + { + System.out.print("}"); + break; + } + System.out.print("\""+list[i]+"\""); + checking=false; + if (list[i+1]==null) + checking=true; + } + } +} diff --git a/Answers/40230112113/phoneNumber.java b/Answers/40230112113/phoneNumber.java new file mode 100644 index 0000000..948fec3 --- /dev/null +++ b/Answers/40230112113/phoneNumber.java @@ -0,0 +1,30 @@ +package t2; + +import java.util.Scanner; + +public class phoneNumber +{ + public static void main(String[] args) + { + search(); + } + public static void search() + { + Scanner sc = new Scanner(System.in); + String num=sc.nextLine(); + if ((num.length()==11)&&((num.charAt(0)=='0')&&(num.charAt(1)=='9'))) + { + System.out.println(num); + } + else if ((num.length()==10)&&(num.charAt(0)=='9')) + { + num=0+num; + System.out.println(num); + } + else + { + System.out.println("Wrong entry. Try again."); + search(); + } + } +} diff --git a/Answers/40230112113/userid.java b/Answers/40230112113/userid.java new file mode 100644 index 0000000..506cfd8 --- /dev/null +++ b/Answers/40230112113/userid.java @@ -0,0 +1,21 @@ +package t2; + +import java.util.Scanner; + +public class userid +{ + public static void main(String[] args) + { + Scanner sc = new Scanner(System.in); + String Id=sc.nextLine(); + if ((Id.length()>13)&&(Id.length()<4)) + { + System.out.println("wrong student ID. please try again"); + main(args); + } + else + { + System.out.println(Id); + } + } +} From e6cd896d1624e46ec08e21636151076dd1e27d9a Mon Sep 17 00:00:00 2001 From: Hazti <161216207+touka6@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:12:43 +0330 Subject: [PATCH 2/4] Update UserFullinformation.java changed some minor things for a better output --- Answers/40230112113/UserFullinformation.java | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/Answers/40230112113/UserFullinformation.java b/Answers/40230112113/UserFullinformation.java index 7d7f4ff..ae4db06 100644 --- a/Answers/40230112113/UserFullinformation.java +++ b/Answers/40230112113/UserFullinformation.java @@ -40,7 +40,7 @@ public static void main(String[] args) //printing process System.out.print("Hello! My name is " + change(Firstname, Lastname) + "."); - System.out.print("My ID is " + Id + ". Here are some of my interests:"); + System.out.print("My ID is " + Id + ". Here are some of my interests: \n"); printit(list); System.out.println("\n You can reach me via my phone number " + num + "."); } @@ -90,21 +90,11 @@ public static String seeifright() } public static void printit(String[] list) { - boolean checking=true; - System.out.print("{"); for (int i=0;i<10;i++) { - if(checking!=true) - System.out.print(","); if(list[i]==null) - { - System.out.print("}"); break; - } - System.out.print("\""+list[i]+"\""); - checking=false; - if (list[i+1]==null) - checking=true; + System.out.println(i+1 + ". " + list[i]); } } } From 53b31c969faf44e4e2fd12ab4f385e026b953200 Mon Sep 17 00:00:00 2001 From: Hazti <161216207+touka6@users.noreply.github.com> Date: Tue, 19 Mar 2024 12:13:42 +0330 Subject: [PATCH 3/4] Update UserFullinformation.java there was a problem with the length of the user id. fixed it. --- Answers/40230112113/UserFullinformation.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Answers/40230112113/UserFullinformation.java b/Answers/40230112113/UserFullinformation.java index ae4db06..87d3265 100644 --- a/Answers/40230112113/UserFullinformation.java +++ b/Answers/40230112113/UserFullinformation.java @@ -81,7 +81,7 @@ public static String seeifright() Scanner sc = new Scanner(System.in); String Id=sc.nextLine(); - if ((Id.length()>=15)||(Id.length()<=2)) + if ((Id.length()>=14)||(Id.length()<=3)) { System.out.println("wrong student ID. please try again."); Id=seeifright(); From 8c79c4bcdc7842c30a81d7dcf70f6cc690e80154 Mon Sep 17 00:00:00 2001 From: touka6 Date: Fri, 22 Mar 2024 01:55:20 +0330 Subject: [PATCH 4/4] new file added --- Answers/40230112113/AllinOne.java | 208 ++++++++++++++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 Answers/40230112113/AllinOne.java diff --git a/Answers/40230112113/AllinOne.java b/Answers/40230112113/AllinOne.java new file mode 100644 index 0000000..d021d6e --- /dev/null +++ b/Answers/40230112113/AllinOne.java @@ -0,0 +1,208 @@ +package t2; + +import java.util.Scanner; +import java.util.Vector; + +/*to whoever is reading this + i'm using vector here because i knew how to use it in cpp + and vector is much better than normal String array + so i did a little searching in google(no it wasn't little. it felt like i could die midway) + and now here it is . vector in java :>*/ + +public class AllinOne +{ + @SuppressWarnings("unchecked") + //it's just a recommendation of vscode + /* i also searched to see what this thing do. + it simply seems that java is much stricter than cpp + and i keep comparing them because i don't know any other programming language + :> */ + public static void main(String[] args) + { + Scanner sc=new Scanner(System.in); + + System.out.println("Please enter your name"); + String Firstname=sc.nextLine(); + String Lastname=sc.nextLine(); + + System.out.println("Please enter your phone number"); + String num=search(); + + System.out.println("Please enter your student ID"); + String Id=seeifright(); + + System.out.println("Please write some of your interests"); + Scanner scan = new Scanner(System.in); + Vector list =new Vector(); + int a=1; + String interests; + String simplified=""; + for (int i=0;i<10;i++) + { + System.out.println("write your word"); + interests = sc.nextLine(); + + list.add(interests); + simplified= String.join(", ", list); + + System.out.println("do you want to stop writing? (enter 0 to stop and 1 to continue)"); + a=scan.nextInt(); + if (a==0) + break; + else + continue; + } + + + + //printing process + String str1=change(Firstname, Lastname); + String information="Hello! My name is " + str1 + ". My ID is " + Id + ". Here are some of my interests: \n" + simplified + ".\n You can reach me via my phone number " + num + "."; + menu(information); + + } + + public static String change(String s1 , String s2) + { + s1=s1.toLowerCase(); + s2=s2.toLowerCase(); + + s1 = s1.substring(0, 1).toUpperCase() + s1.substring(1); + s2 = s2.substring(0, 1).toUpperCase() + s2.substring(1); + + String s3=s1+" "+s2; + + return s3; + } + public static String search() + { + Scanner sc = new Scanner(System.in); + String num=sc.nextLine(); + + if ((num.length()==11)&&((num.charAt(0)=='0')&&(num.charAt(1)=='9'))) + { + return num; + } + else if ((num.length()==10)&&(num.charAt(0)=='9')) + { + num=0+num; + } + else + { + System.out.println("Wrong entry. Try again."); + num=search(); + } + return num; + } + public static String seeifright() + { + Scanner sc = new Scanner(System.in); + String Id=sc.nextLine(); + + if ((Id.length()>=14)||(Id.length()<=3)) + { + System.out.println("wrong student ID. please try again."); + Id=seeifright(); + } + return Id; + } + public static void menu(String information) + { + Scanner scans= new Scanner(System.in); + System.out.println("****MENU****"); + System.out.println("1-Encoded" + "\n" + "2-Decoded" + "\n" + "3-Exit"); + int a=scans.nextInt(); + + if (a==3) + System.exit(0); + + if (a==1) + { + System.out.println("now enter the amount of shift you want"); + int shift=scans.nextInt(); + char[] newerstr=Encoder(information , shift); + System.out.println(newerstr); + menu(information); + } + else if (a==2) + { + Decoder(information); + menu(information); + } + } + + public static char[] Encoder(String str , int shift) + { + String[] newstr=str.split(" "); + char[] newerstr=new char[256]; + int t=0; + for (int i=0;i='A')&&(newstr[i].charAt(j)<='z')) + { + if ((ascii>122)) + { + for (int k=1;k<=shift;k++) + { + int z=1; + int replacement=0; + if (((int)newstr[i].charAt(j)+k)>=122) + { + replacement=97+z; + } + if (z+k==shift) + { + newerstr[t]=(char)replacement; + t++; + break; + } + else + z++; + } + } + else if((ascii>90)&&((newstr[i].charAt(j)>='A')&&(newstr[i].charAt(j)<='Z'))) + { + for (int k=1;k<=shift;k++) + { + int z=1; + int replacement=0; + if (((int)newstr[i].charAt(j)+k)>=90) + { + replacement=65+z; + } + if (z+k==shift) + { + newerstr[t]=(char)replacement; + t++; + break; + } + else + z++; + } + } + else + { + newerstr[t]=(char)ascii; + t++; + } + } + else + { + newerstr[t]=newstr[i].charAt(j); + t++; + } + } + newerstr[t]=' '; + t++; + } + return newerstr; + } + + public static void Decoder(String str) + { + System.out.println(str); + } +}