Anil
BAN USER
- 4of 4 votes
Answerswrite a java program to reverse a string.
- Anil in United States| Report Duplicate | Flag | PURGE
Adobe Quality Assurance Engineer - 0of 0 votes
AnswersWrite a java program to read a file and get different words and also print number of occurences of each word.
- Anil in United States| Report Duplicate | Flag | PURGE
Adobe Quality Assurance Engineer Java - 0of 0 votes
AnswersWrite a program to read a give directory in your hard drive and list all the sub directories and files as hierarchy structure.
- Anil in United States for DLP| Report Duplicate | Flag | PURGE
Symantec Quality Assurance Engineer Algorithm - 0of 0 votes
AnswersWrite a program to shuffle a deck of 52 cards and shuffle them equally to 4 players
- Anil in United States for DLP| Report Duplicate | Flag | PURGE
Symantec Quality Assurance Engineer Java - 0of 0 votes
AnswersWrite a program that takes an array of numbers, and then prints out all the possible pairs of numbers that sum up to the value N.
- Anil in United States for AWS
E.g., if the array contains the numbers {0, 1, 2, 2, 3, 4, 5} and the target value N is 4, then the output would be (0, 4), (1, 3), (2, 2).| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Java - 0of 0 votes
AnswersEMP (empno, name, deptno, salary)
- Anil in United States for AWS
DEPT (deptno, name)
Write a SQL query that tells me the average salary by department name.| Report Duplicate | Flag | PURGE
Amazon Quality Assurance Engineer Database
This one works on (N^2)/2
public class SumInArr2 {
public static void findSumHashMap(int[] arr, int key) {
for(int i=0;i<=arr.length-2;i++){
for(int j=i+1;j<=arr.length-1;j++){
if (key-arr[i]==arr[j]){
System.out.println(arr[i]+ "index:"+i+" "+arr[j]+ "index:"+j);}}} }
public static void main(String[] args) {
int[] arr={32,40,28,37,4,12,2,51,23,50,20,56};
int sum = 60;
findSumHashMap(arr,sum); }}
I think using hashmap duplicates cannot be allowed. This works on log(n).When you add a duplicate it updates the value to later one. here is java code
public class SumInArr3 {
public static void findSumHashMap(int[] arr, int key) {
Map<Integer, Integer> valMap = new HashMap<Integer, Integer>();
for (int i = 0; i < arr.length; i++) {
valMap.put(arr[i], i); }
for (int i = 0; i < arr.length; i++) {
if (valMap.containsKey(key - arr[i])
&& valMap.get(key - arr[i]) != i) {
if (valMap.get(key - arr[i]) < i) {
int diff = key - arr[i];
System.out.println(arr[i] + " " + diff);}}}}
public static void main(String[] args) {
int[] arr = { 32, 40, 28, 37, 4, 12, 2, 51, 23, 50, 20, 56, 32,-50,110 };
int sum = 60;
findSumHashMap(arr, sum); }}
public class StringSplit {
public static void main(String[] args) {
String append = "I am Chandu";
String[] splits = append.split(" ");
append="";
System.out.println("splits.size: " + splits.length);
for(int i=0; i<splits.length;i++){
append=append+splits[i]+"abc";}
System.out.println(append); }}
Web services work on RESTful and SOAP protocols..
On SOAP you need to have a proxy set up. Your IDE's like Jdeveloper and Eclipse can create those proxies. The proxy will generate the API's that web services are exposing. You can have the proxy in any language like C# or JAVA or anything of your choice. Once you have the proxy set up you can test the web services using API level programming.
import java.lang.*;
public class ArraySort {
public static void main(String[] args) {
char[] ch1= {'A', 'B', 'A', 'C', 'A', 'B', 'B', 'C', 'A'};
char[] ch2= {'A', 'B', 'C'};
char[]ch3=new char[ch1.length];
int k=0;
for (int i=0;i<ch2.length;i++){
for(int j=0;j<ch1.length;j++){
if((Character.toUpperCase(ch2[i])==Character.toUpperCase(ch1[j]))){
ch3[k]=ch1[j];
k++;
}}}
System.out.println(ch3);}}
import java.util.*;
public class StringReverse{
public static void main(String[] args) {
String st1= "This is a new string and want it to be reversed";
char[] ch1= st1.toCharArray();
int length =ch1.length-1;
for(int i=length;i>=0;i--){
System.out.print(ch1[i]);
}}}
Hi Folks,
I have 80% of this working. If I have the base to the power of fraction, there there is problem. Else this program takes number of inputs mentioned in java.lang.math.pow doc..
import java.lang.Math;
public class PowClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double a = 3;
int b =(int) 2;
System.out.println("computed value is: " + powFunc(a, b));
System.out.println(java.lang.Math.pow(a, b));
}
public static double powFunc(double a, int b) {
double value = 1;
if ((a == 0) && (b < 0)) {
value = Double.POSITIVE_INFINITY;
return value;
}
if (a == Double.POSITIVE_INFINITY && b == Double.POSITIVE_INFINITY) {
value = Double.POSITIVE_INFINITY;
return value;
}
if (a == 1 && b == Double.POSITIVE_INFINITY) {
value = Double.NaN;
return value;
}
if (a == 0)
return a;
if (b == 0)
return 1;
if ((a < 0) && (b % 1 != 0)) {
value = Double.NaN;
return value;
}
if (b % 1 != 0) {
double var = Math.round(b);
b=(int)(b-var);
while (var-- > 0)
value *= a;
a = a * b;
System.out.println(a);
value *= a;
return value;
} else if (b < 0) {
double negIndx = -b;
while (negIndx-- > 0)
value *= a;
return 1 / value;
} else {
while (b-- > 0)
value *= a;
return value;
}
}
}
Repannadwilliams31, Applications Developer at National Instruments
I am Anthony, Human Resources specialist with a decade of successful experience in hiring and employee management.I am a ...
RepJanetCKeel, Accountant at ABC TECH SUPPORT
Hey i am Janet i am from Us and i leave here from last 4 years .My job is truck ...
RepAriaScott, abc at 247quickbookshelp
I am a qualified medical representative who has been in the industry for many years and has proven sales experience ...
Repamyfreynold, abc at ADP
Hi Everyone, I'm Ammy. I love to build props...everything from a casket to pneumatic monsters.My current pet ...
RepFreyaShaw, Attorney at 247quickbookshelp
Excellent verbal and written communication skills to aid in properly presenting positions, arguing cases, and getting positive outcomes for clients ...
Reprizzafilher, Java Developer at Achieve Internet
Sorter with 3+ years of experience , performs duties in a safe manner in compliance with all local, state, and federal ...
RepDedicated and professional insurance manager with many years of experience. I love my work here. I have learned many things ...
Repjosiredhima, AT&T Customer service email at Aricent
I am an architect with three years experience planning and designing commercial buildings. I am working as principal architect on ...
RepLaylaLee, abc at AMD
Creative and dedicated photo editor with experience in photojournalism and marketing material development. I like to explore Best tantrik in ...
RepNaomiAdams, abc at 8x8
Passionate educator for nearly 5 years with a strong desire to help students recognize the connection between learning and experience ...
RepLiamLee, abc at ADP
Proven leadership skills that have helped projects get completed within the time and budget constraints, Dedication to following appropriate safety ...
Repshanamkyler38, AT&T Customer service email at ABC TECH SUPPORT
Hi, I am Shana and I live in Chicago USA .I am working as a Tax preparer in an Adaptabiz ...
Replarrymmapp, Android test engineer at Software AG
Hello, I am name and I live in a city, USA. I am a professional's Podiatric doctor. I am ...
Repbarrondanielle057, Android test engineer at A9
My name is Danielle and I am working as a Contract manager. I love this job.and nowadays I am ...
Reproseyasalazar, Animator at Achieve Internet
I have strong english language skills and communication skills.Good written and oral communication skills.I collect knowledge of Best ...
RepRuthOrvis, AT&T Customer service email at 8x8
Hey I am Ruth Working as a branch manager in a bank.I have worked here for the last 4 ...
RepShirleyMHansen, Project Leader at Chelsio Communications
I am Physical Therapy Aide with 3 years experience in hospital. I like to build up my knowledge of various ...
RepAadavThomas, abc at A9
I am a well skilled and innovative Industrial Designer who focuses on taking products, noting product ideas and making them ...
Repethelsizer, SDET at ADP
I am Ethel , creative news writer with 5+ years of experience. Have great storytelling skills , wrote and delivered high quality ...
Repaaronmdunlap6, Area Sales Manager at Achieve Internet
Hi, I am an HR Analyst with extensive experience delivering innovative solutions at the corporate level. Expertise in employee relations ...
Reproseljannet75, Financial Software Developer at Abs india pvt. ltd.
Je suis jannet , une conseillère en voyages qui conseille les clients sur les options de voyage et les voyages organisés ...
Repsallieroliphant, Project Leader at Wissen Technology
With years of experience I can guarantee you that our licensed company specializes in furnace maintenance scarborough, air conditioners and ...
Repharveyoberion, Analyst at AMD
Hi, I am Harvey, from the USA. I am working as a soil scientist. I study soil as a natural ...
Repaalvinbrowne, Android Engineer at ASAPInfosystemsPvtLtd
Working as an Agricultural laborer at Mars Music I maintain yields like natural products, vegetables, grains, and nuts, or take ...
Repdorarwoods, Kuwait airways reservations at Aspire Systems
I am an Application engineer in the network chef company. In my free time, I enjoy reading programming and technology ...
RepDavidTBevins, Apple Phone Number available 24/7 for our Customers at AMD
Hi am working as a writer and i wrote many books.Mostly i write books related to Magic and my ...
RepChloePerez, cashier at POS
Versatile cashier with exemplary cash register system skills and proven commitment to store cleanliness and safely. Learning new and knowledgeable ...
Repcorinnedonon, Backend Developer at A9
I am Corinne, a highly organised, professional and self-motivated Dietitian with a great passion for nutrition and people’s well-being ...
Repaaronyocoma, U.S. marshal at Pacific Stereo
Working as U.S. marshal at Pacific Stereo numerous years . I encountered heaps of things . With this I likewise like ...
Repmakaylaangwin, Backend Developer at Abs india pvt. ltd.
I'm part owner of Bloom Floral Land, an Australian floral design company. Life is really short, try to smile ...
class FileCountWords {
- Anil April 30, 2013public static void main(String[] args) throws Exception {
Scanner input = new Scanner(System.in);
System.out.println("Enter File name with path: ");
String filename = input.next();
File f = new File(filename);
BufferedReader br = new BufferedReader(new FileReader(f));
StringBuffer buffer = new StringBuffer();
String str;
while ((str = br.readLine()) != null) {
buffer.append(str);
buffer.append(" ");
}
ArrayList<String> list = new ArrayList<String>();
StringTokenizer st = new StringTokenizer(buffer.toString()
.toLowerCase());
while (st.hasMoreTokens()) {
String s = st.nextToken();
list.add(s);
}
while (!list.isEmpty()) {
int i = 0;
String uniqueStr = list.get(i);
int index = list.lastIndexOf(uniqueStr);
int uniqueStrCount = 1;
while (i != index) {
uniqueStrCount++;
list.remove(index);
index = list.lastIndexOf(uniqueStr);
}
System.out.println("count of word " + "-" + uniqueStr + "-"
+ " in the file is : " + uniqueStrCount);
list.remove(i);
i++;
}
}
}