Skip to content

Commit

Permalink
added till a1q3.java
Browse files Browse the repository at this point in the history
  • Loading branch information
MartyMiniac committed Jan 18, 2020
1 parent dbbbfe6 commit 0df3f84
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Semester 2 (DSA)/assignment 1/a1q1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;
class a1q1
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the Value of a: ");
int a=in.nextInt();
System.out.print("Enter the value of b: ");
int b=in.nextInt();
System.out.print("Enter the value of c: ");
int c=in.nextInt();
boolean k=false;
if(a+b==c || a==b-c || a*b==c)
k=true;
if(k)
{
System.out.print(a+", "+b+", "+c+" can be used in an arithmatic formula");
}
else
{
System.out.print(a+", "+b+", "+c+" cannot be used in an arithmatic formula");
}
}
}
13 changes: 13 additions & 0 deletions Semester 2 (DSA)/assignment 1/a1q2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.*;
class a1q2
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter the Number : ");
int n=in.nextInt();
double t1=Math.log(n), t2=Math.log(2);
int ans=(int)(t1/t2);
System.out.print(n+" must be divided by two "+ans+" times to get a value less than 2");
}
}
48 changes: 48 additions & 0 deletions Semester 2 (DSA)/assignment 1/a1q3.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import java.util.*;
class a1q3
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
char ch[] = {'a','r','b','o','n'};
a1q3 ob = new a1q3();
int i=1;
for(int a=0; a<5; a++)
{
for(int b=0; b<5; b++)
{
for(int c=0; c<5; c++)
{
for(int d=0; d<5; d++)
{
for(int e=0; e<5; e++)
{
String s=""+ch[a]+ch[b]+ch[c]+ch[d]+ch[e];
if(ob.check(s))
{
System.out.println(i+") "+s);
i++;
}
}
}
}
}
}
}
public boolean check(String s)
{
boolean k=true;
for(int a=0; a<s.length()-1; a++)
{
for(int b=a+1; b<s.length(); b++)
{
if(s.charAt(a)==s.charAt(b))
{
k=false;
break;
}
}
}
return k;
}
}

0 comments on commit 0df3f84

Please sign in to comment.