Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Answers/40230112136/.gitignore
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions Answers/40230112136/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Answers/40230112136/.idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Answers/40230112136/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Answers/40230112136/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Answers/40230112136/full.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
147 changes: 147 additions & 0 deletions Answers/40230112136/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import java.util.Objects;
import java.util.Scanner;

public class Main {

static String fullname(String firstname , String lastname)
{
String lowfirst = firstname.toLowerCase();
String lowlast = lastname.toLowerCase();
String first = lowfirst.substring(0, 1).toUpperCase() + lowfirst.substring(1);
String last = lowlast.substring(0, 1).toUpperCase() + lowlast.substring(1);
return (first + ' ' + last);
}

static String phonenumber(String number)
{
if(number.length()!=10){return "wrong";}
char[] num = number.toCharArray();
if(num[0]!= '9'){return "wrong";}
if (number.matches("[0-9]+")==false){return "wrong";}
String resualt = '0'+ number;
return resualt;
}

static String userid(String id)
{
if(id.length()>13 || id.length()<4){return "wrong";}
if (id.matches("[0-9]+")==false){return "wrong";}
else{return id;}
}

static String[] intrest(){

System.out.println("please enter your interst");
Scanner scanner = new Scanner(System.in);
String[] intrests = new String[10];
int i;
for( i=0 ; i<10 ; i++)
{
intrests[i] = scanner.nextLine();
System.out.println("if you dont want to add more to your intrests, please enter NO otherwise press any key");
String s1= scanner.nextLine();
if(Objects.equals(s1, "NO")){break;}
}
if(i==10){System.out.println("You have reached the limit!");}
return intrests;
}

static String full(String name, String shomar , String userid, String[] alaqe){
String S= "Hello! My name is " + name + ". My ID is " + userid +". Here are some of my interests:";
String M="\n";
for(int j=0 ; j<= alaqe.length ; j++){
if(alaqe[j]==null){break;}
M= M + ( j+1 + "." + alaqe[j]+ "\n");
}
String N= "You can reach me via my phone number "+ 0+shomar +".";
return S+M+N;
}
static String ceasar(String payam , int shift)
{
while(true){
if(shift<27){break;}
else{shift= shift-26;}
}
char[] horof= payam.toCharArray();
for(int i=0 ; i< horof.length ; i++)
{
if( horof[i]>=65 && horof[i]<=90){
if(horof[i] + shift> 90){ horof[i] = (char)(horof[i] + shift - 26);}
else{horof[i] = (char)(horof[i] + shift);}
}
if( horof[i]>=97 && horof[i]<= 122){
if(horof[i] + shift> 122 ){ horof[i] = (char)(horof[i] + shift - 26);}
else{horof[i] = (char)(horof[i] + shift);}
}
}
return String.valueOf(horof);
}
static String undoceasar(String payam , int shift)
{
while(true){
if(shift<27){break;}
else{shift= shift-26;}
}
char[] horof= payam.toCharArray();
for(int i=0 ; i< horof.length ; i++)
{
if( horof[i]>=65 && horof[i]<=90){
if(horof[i] - shift< 65){ horof[i] = (char)(horof[i] - shift + 26);}
else{horof[i] = (char)(horof[i] - shift);}
}
if( horof[i]>=97 && horof[i]<= 122){
if(horof[i] - shift< 97 ){ horof[i] = (char)(horof[i] - shift + 26);}
else{horof[i] = (char)(horof[i] - shift);}
}
}
return String.valueOf(horof);
}

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("please enter your firstname");
String first = scanner.nextLine();
System.out.println("please enter your lastname");
String last = scanner.nextLine();
String esm = fullname(first , last);
System.out.println("please enter your phonenumber");
String number = scanner.nextLine();
while(true)
{
if(phonenumber(number)=="wrong")
{
System.out.println("Wrong entry. Try again.");
number = scanner.nextLine();
}
else{
break;
}
}
System.out.println("please enter your id");
String id = scanner.nextLine();
while(true) {
if(userid(id)=="wrong"){
System.out.println("Wrong entry. Try again.");
id = scanner.nextLine();
}
else {
System.out.println(userid(id));
break;
}
}
String[] alayeq = intrest();
System.out.println("How do you want to see your informations? 1.normal 2.coded");
int op =scanner.nextByte();
if(op==1){ System.out.println( full( esm , number , id , alayeq));}
if(op==2){
System.out.println("please enter a number for your shift");
int shift=scanner.nextByte();
System.out.println( ceasar( full( esm , number , id , alayeq),shift));
System.out.println("If you want to see the decode version please enter YES");
String decode= scanner.next();
String coded=ceasar( full( esm , number , id , alayeq) , shift);
if(Objects.equals(decode, "YES")){System.out.println(undoceasar( coded,shift));}
}

}
}