Professional Documents
Culture Documents
Assignmt
Assignmt
”
a. I/P -> Take User Name as Input.
Ensure UserName has min 3 char
b. Logic -> Replace <<UserName>> with the proper name
c. O/P -> Print the String with User Name
solution=>>>>>>
package BridgeLabs;
import java.util.Scanner;
public class Template {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the name and name length should be greater than
3");
String name = sc.nextLine();
if(name.length()>3) {
System.out.println("Hello "+name+" How are you?");
}else {
System.out.println("name length should be greater than 3");
}
}
}
<-----question no 2--->
2. Simulate Stopwatch Program
a. Desc -> Write a Stopwatch Program for measuring the time that elapses between
the start and end clicks
b. I/P -> Start the Stopwatch and End the Stopwatch
c. Logic -> Measure the elapsed time between start and end
d. O/P -> Print the elapsed time. Intermediate
solution=>>>>>>
package BridgeLabs;
import java.util.Scanner;
<-----question no 4--->
2. Take a string from user at runtime.
Check that using those characters of string is it possible to make a palindrome
string?
If yes then print the palindrome string.
E.g. abcde O/p: palindrome not possible.
E.g. abcabc O/p: palindrome possible. abccba
solution=>>>>>>
package BridgeLabs;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
public class Palindromes {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the String!");
String str = sc.nextLine();
findPalindromes(str);
}
}
}
<-----question no 5--->
package BridgeLabs;
import java.util.LinkedList;
public class ResverseLinkList {
public static void main(String[] args) {
LinkedList ll= new LinkedList();
for(int i=1;i<10;i++) {
ll.add(i);
}
System.out.println("Before Reverse "+ll);
reverseLinkList(ll);
}
private static void reverseLinkList(LinkedList ll) {
int size = ll.size();
for (int i =0; i <size/2; i++) {
int temp = (Integer) ll.get(i);
ll.set(i, ll.get((size-1)-i));
ll.set((size-1)-i,temp);
System.out.println("After Reverse Using The Stack "+ll);
}
}
}
<-----question no 5--->
b. Reverse the link using recursion
solution=>>>>>>
package BridgeLabs;
import java.util.LinkedList;
}
}
<-----question no 5--->
c. Reverse the link using stack.
solution=>>>>>>
package BridgeLabs;
import java.util.LinkedList;
import java.util.Stack;