SlideShare a Scribd company logo
1 of 6
Download to read offline
Write the code above and the ones below in netbeans IDE 8.1
3. (Eliminate duplicates) Write a method that returns a new array by eliminating the duplicate
values in the array using the following method header: public static int[]
eliminateDuplicates(int[] list) Write a test program that reads in ten integers, invokes the method,
and displays the result. Here is the sample run of the program:
Enter ten numbers: 1 2 3 2 1 6 3 4 5 2 [Enter]
The distinct numbers are: 1 2 3 6 4 5
4. (Sort students) Write a program that prompts the user to enter the number of students, the
students’ names, and their scores, and prints student names in decreasing order of their scores.
Solution
Please follow the code and comments for description :
a)
CODE :
import java.util.Scanner;
public class MeanSD {
public static double deviation (double[] x) { // method to return the deviation
double sum = 0, mean = 0, deviation = 0; // required initialisations
double[] temp = new double[10]; // temporary array
for (int i = 0; i < 10; i++) //calculate the standard deviation
{
temp[i] = Math.pow((x[i] - mean), 2); // assigning the value to the array
sum += temp[i]; // adding up the values
}
mean = sum / 10; // getting the mean
deviation = Math.sqrt(mean); // calculating the deviation
return deviation; // returning the deviation
}
public static double mean (double[] x) { // method to return themean of the values entered
double sum = 0, mean; // required initialisations
for (int i = 0; i < 10; i++) //Take input in the array
{
sum += x[i]; //sum of all elements
}
mean = sum / 10; // calculating the mean
return mean; // returning the mean value
}
public static void main(String[] args) { // driver method
System.out.println("Enter the 10 numbers."); // prompt to enter the data
Scanner in = new Scanner(System.in); // scanner class to get the data from the user
double[] arr = new double[10]; // array that saves the data
double sum = 0, mean = 0, deviation = 0; // required initialisations
for (int i = 0; i < 10; i++) //Take input in the array
{
System.out.print("Enter a number : "); // prompt to enter the number
arr[i] = in.nextDouble(); // getting the data from the console
}
mean = mean(arr); // calling the method to return the mean value
System.out.println("Mean : " + mean); //Display mean of all elements
deviation = deviation(arr); // calling the method to return teh deviation value
System.out.println("Deviation : " + deviation); // display the result
}
}
OUPTPUT :
Enter the 10 numbers.
Enter a number : 1
Enter a number : 2
Enter a number : 3
Enter a number : 4
Enter a number : 5
Enter a number : 6
Enter a number : 7
Enter a number : 8
Enter a number : 9
Enter a number : 10
Mean : 5.5
Deviation : 6.2048368229954285
b)
CODE :
import java.util.Scanner;
public class MyDuplicateElements {
public static int[] eliminateDuplicates(int[] input) { // method to remove the duplicates
int j = 0; // required initialisations
int i = 1;
//return if the array length is less than 2
if (input.length < 2) { // checking for the input data
return input; // returning the data
}
while (i < input.length) { // iterating over the data int the list
if (input[i] == input[j]) { // checking for the array data elements
i++; // incrementing the index value
} else {
input[++j] = input[i++];
}
}
int[] output = new int[j + 1]; // resultant array
for (int k = 0; k < output.length; k++) { // iterating over the loop
output[k] = input[k]; // assigning the data
}
return output; // returning the result
}
public static void main(String a[]) { // driver method
Scanner in = new Scanner(System.in); // scanner class to get the data from the user
int[] array = new int[10];
System.out.println("Enter the Elements Please : "); // prompt to enter the data
for (int i = 0; i < 10; i++) //Take input in the array
{
System.out.print("Enter a number : "); // prompt to enter the number
array[i] = in.nextInt(); // getting the data from the console
}
int[] output = eliminateDuplicates(array); // calling the method to return the duplicate free
elements
System.out.println("The Duplicate Free Array is : ");
for (int i : output) {
System.out.print(i + " ");
}
}
}
OUPTPUT :
Enter the Elements Please :
Enter a number : 1
Enter a number : 2
Enter a number : 2
Enter a number : 6
Enter a number : 4
Enter a number : 3
Enter a number : 3
Enter a number : 4
Enter a number : 7
Enter a number : 8
The Duplicate Free Array is :
1 2 6 4 3 4 7 8
c)
CODE :
import java.util.*;
public class SortingtheStudents { // class to run the code
public static void main(String[] args) { // driver class
Scanner input = new Scanner(System.in); // scanner class to get the data
System.out.print("Enter the total number of Students: "); // prompt to enter the data
int totalStudents = input.nextInt(); // getting the data
String[] stNames = new String[totalStudents]; // array to save the data
int[] scoreData = new int[totalStudents];
for (int i = 0; i < totalStudents; i++) { // iterating over the loop
System.out.print("Enter the Student's Name: "); // student name enter
stNames[i] = input.next();
System.out.print("Enter the Student's Score: "); // prompt to enter the score
scoreData[i] = input.nextInt();
}
descendSort(stNames, scoreData); // calling the method
System.out.println("The Order of the Students based on the Scores is : ");
System.out.println(Arrays.toString(stNames)); // printing the result
}
public static void descendSort(String[] stNames, int[] scoreData) { // method to sort the data
for (int i = scoreData.length - 1; i >= 1; i--) { // iterating over the loop
String temp; // required initialisations
int currentMax = scoreData[0];
int currentMaxIndex = 0;
for (int j = 1; j <= i; j++) { // iterating over the loop to get the data
if (currentMax > scoreData[j]) { // checking the conditions
currentMax = scoreData[j];
currentMaxIndex = j; // assigning the values
}
}
if (currentMaxIndex != i) {
temp = stNames[currentMaxIndex];
stNames[currentMaxIndex] = stNames[i];
stNames[i] = temp;
scoreData[currentMaxIndex] = scoreData[i];
scoreData[i] = currentMax; // assigning the values
}
}
}
}
OUPTPUT :
Enter the total number of Students: 3
Enter the Student's Name: John
Enter the Student's Score: 98
Enter the Student's Name: Carter
Enter the Student's Score: 58
Enter the Student's Name: MArk
Enter the Student's Score: 65
The Order of the Students based on the Scores is :
[John, MArk, Carter]
Hope this is helpful.

More Related Content

Similar to Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf

C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfyamew16788
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfannapurnnatextailes
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...Nithin Kumar,VVCE, Mysuru
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfFootageetoffe16
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdfaravlitraders2012
 
import java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfimport java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfapexelectronices01
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdfactocomputer
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdffashioncollection2
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specificationsrajkumari873
 
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdfTeacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdfkareemangels
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfarrowvisionoptics
 
the code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdfthe code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdfrajatchugh13
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerAiman Hud
 

Similar to Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf (20)

C++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdfC++ Nested loops, matrix and fuctions.pdf
C++ Nested loops, matrix and fuctions.pdf
 
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdfDigits.javapackage week04;import java.util.Scanner; public cla.pdf
Digits.javapackage week04;import java.util.Scanner; public cla.pdf
 
PROGRAMMING QUESTIONS.docx
PROGRAMMING QUESTIONS.docxPROGRAMMING QUESTIONS.docx
PROGRAMMING QUESTIONS.docx
 
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
VTU Design and Analysis of Algorithms(DAA) Lab Manual by Nithin, VVCE, Mysuru...
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
Creating Interface- Practice Program 6.docx
Creating Interface- Practice Program 6.docxCreating Interface- Practice Program 6.docx
Creating Interface- Practice Program 6.docx
 
Java practical
Java practicalJava practical
Java practical
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
 
import java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdfimport java.util.Scanner;public class Digits { public static v.pdf
import java.util.Scanner;public class Digits { public static v.pdf
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdf
 
Write a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdfWrite a method called uniqueNumbers that takes an int array as param.pdf
Write a method called uniqueNumbers that takes an int array as param.pdf
 
Quest 1 define a class batsman with the following specifications
Quest  1 define a class batsman with the following specificationsQuest  1 define a class batsman with the following specifications
Quest 1 define a class batsman with the following specifications
 
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdfTeacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
Teacher.javaimport java.util.Arrays; import java.util.Scanner;.pdf
 
Create a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdfCreate a class named Student that has the following member variables.pdf
Create a class named Student that has the following member variables.pdf
 
the code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdfthe code below is a recommendation system application to suggest a s.pdf
the code below is a recommendation system application to suggest a s.pdf
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 

More from arihantmum

In 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfIn 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfarihantmum
 
In a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfIn a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfarihantmum
 
I need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfI need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfarihantmum
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfarihantmum
 
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfHeading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfarihantmum
 
Explain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfExplain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfarihantmum
 
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfExplain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfarihantmum
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfarihantmum
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfarihantmum
 
Describe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfDescribe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfarihantmum
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfarihantmum
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfarihantmum
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfarihantmum
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfarihantmum
 
Amon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfAmon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfarihantmum
 
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfA box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfarihantmum
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfarihantmum
 
A bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfA bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfarihantmum
 
Xavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfXavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfarihantmum
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdfarihantmum
 

More from arihantmum (20)

In 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdfIn 2012, the percent of American adults who owned cell phones and us.pdf
In 2012, the percent of American adults who owned cell phones and us.pdf
 
In a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdfIn a multiple regression model, the error term e is assumed tohave.pdf
In a multiple regression model, the error term e is assumed tohave.pdf
 
I need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdfI need help with this one method in java. Here are the guidelines. O.pdf
I need help with this one method in java. Here are the guidelines. O.pdf
 
help me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdfhelp me Java projectI put problem and my own code in the linkmy .pdf
help me Java projectI put problem and my own code in the linkmy .pdf
 
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdfHeading ibe the following picture. Main computer UART DTE Serial chan.pdf
Heading ibe the following picture. Main computer UART DTE Serial chan.pdf
 
Explain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdfExplain how TWO (2) different structural features can be used to dis.pdf
Explain how TWO (2) different structural features can be used to dis.pdf
 
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdfExplain two (2) alternative ways in which plants can obtain nutrient.pdf
Explain two (2) alternative ways in which plants can obtain nutrient.pdf
 
Couldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdfCouldnt find the right subject that it belongs to...There ar.pdf
Couldnt find the right subject that it belongs to...There ar.pdf
 
Consider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdfConsider the following C code snippet C codevoid setArray(int.pdf
Consider the following C code snippet C codevoid setArray(int.pdf
 
Describe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdfDescribe a mechanism that the body uses to prevent a mutation from be.pdf
Describe a mechanism that the body uses to prevent a mutation from be.pdf
 
classify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdfclassify domian of life differencesSolutionClassify the domain.pdf
classify domian of life differencesSolutionClassify the domain.pdf
 
Compare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdfCompare and contrast the development of a WBS in traditional project.pdf
Compare and contrast the development of a WBS in traditional project.pdf
 
B. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdfB. You are an evolutionary biologist in a heated argument with a cre.pdf
B. You are an evolutionary biologist in a heated argument with a cre.pdf
 
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdfAssume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
Assume Hashtable is a simple array of size 8, with indices 0..7. Num.pdf
 
Amon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdfAmon the following, which has the lowest levels of dissolved iron.pdf
Amon the following, which has the lowest levels of dissolved iron.pdf
 
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdfA box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
A box contains 10 red balls and 40 black balls. Two balls are drawn .pdf
 
As late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdfAs late as 1992, the United States was running budget deficits of ne.pdf
As late as 1992, the United States was running budget deficits of ne.pdf
 
A bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdfA bacteriophage population is introduced to a bacterial colony that .pdf
A bacteriophage population is introduced to a bacterial colony that .pdf
 
Xavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdfXavier and Yolanda both have classes that end at noon and they agree .pdf
Xavier and Yolanda both have classes that end at noon and they agree .pdf
 
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
1. Low platelet count is a recessively inherited trait. Reevaluation.pdf
 

Recently uploaded

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf

  • 1. Write the code above and the ones below in netbeans IDE 8.1 3. (Eliminate duplicates) Write a method that returns a new array by eliminating the duplicate values in the array using the following method header: public static int[] eliminateDuplicates(int[] list) Write a test program that reads in ten integers, invokes the method, and displays the result. Here is the sample run of the program: Enter ten numbers: 1 2 3 2 1 6 3 4 5 2 [Enter] The distinct numbers are: 1 2 3 6 4 5 4. (Sort students) Write a program that prompts the user to enter the number of students, the students’ names, and their scores, and prints student names in decreasing order of their scores. Solution Please follow the code and comments for description : a) CODE : import java.util.Scanner; public class MeanSD { public static double deviation (double[] x) { // method to return the deviation double sum = 0, mean = 0, deviation = 0; // required initialisations double[] temp = new double[10]; // temporary array for (int i = 0; i < 10; i++) //calculate the standard deviation { temp[i] = Math.pow((x[i] - mean), 2); // assigning the value to the array sum += temp[i]; // adding up the values } mean = sum / 10; // getting the mean deviation = Math.sqrt(mean); // calculating the deviation return deviation; // returning the deviation } public static double mean (double[] x) { // method to return themean of the values entered double sum = 0, mean; // required initialisations for (int i = 0; i < 10; i++) //Take input in the array {
  • 2. sum += x[i]; //sum of all elements } mean = sum / 10; // calculating the mean return mean; // returning the mean value } public static void main(String[] args) { // driver method System.out.println("Enter the 10 numbers."); // prompt to enter the data Scanner in = new Scanner(System.in); // scanner class to get the data from the user double[] arr = new double[10]; // array that saves the data double sum = 0, mean = 0, deviation = 0; // required initialisations for (int i = 0; i < 10; i++) //Take input in the array { System.out.print("Enter a number : "); // prompt to enter the number arr[i] = in.nextDouble(); // getting the data from the console } mean = mean(arr); // calling the method to return the mean value System.out.println("Mean : " + mean); //Display mean of all elements deviation = deviation(arr); // calling the method to return teh deviation value System.out.println("Deviation : " + deviation); // display the result } } OUPTPUT : Enter the 10 numbers. Enter a number : 1 Enter a number : 2 Enter a number : 3 Enter a number : 4 Enter a number : 5 Enter a number : 6 Enter a number : 7 Enter a number : 8 Enter a number : 9 Enter a number : 10 Mean : 5.5 Deviation : 6.2048368229954285 b)
  • 3. CODE : import java.util.Scanner; public class MyDuplicateElements { public static int[] eliminateDuplicates(int[] input) { // method to remove the duplicates int j = 0; // required initialisations int i = 1; //return if the array length is less than 2 if (input.length < 2) { // checking for the input data return input; // returning the data } while (i < input.length) { // iterating over the data int the list if (input[i] == input[j]) { // checking for the array data elements i++; // incrementing the index value } else { input[++j] = input[i++]; } } int[] output = new int[j + 1]; // resultant array for (int k = 0; k < output.length; k++) { // iterating over the loop output[k] = input[k]; // assigning the data } return output; // returning the result } public static void main(String a[]) { // driver method Scanner in = new Scanner(System.in); // scanner class to get the data from the user int[] array = new int[10]; System.out.println("Enter the Elements Please : "); // prompt to enter the data for (int i = 0; i < 10; i++) //Take input in the array { System.out.print("Enter a number : "); // prompt to enter the number array[i] = in.nextInt(); // getting the data from the console } int[] output = eliminateDuplicates(array); // calling the method to return the duplicate free elements System.out.println("The Duplicate Free Array is : "); for (int i : output) {
  • 4. System.out.print(i + " "); } } } OUPTPUT : Enter the Elements Please : Enter a number : 1 Enter a number : 2 Enter a number : 2 Enter a number : 6 Enter a number : 4 Enter a number : 3 Enter a number : 3 Enter a number : 4 Enter a number : 7 Enter a number : 8 The Duplicate Free Array is : 1 2 6 4 3 4 7 8 c) CODE : import java.util.*; public class SortingtheStudents { // class to run the code public static void main(String[] args) { // driver class Scanner input = new Scanner(System.in); // scanner class to get the data System.out.print("Enter the total number of Students: "); // prompt to enter the data int totalStudents = input.nextInt(); // getting the data String[] stNames = new String[totalStudents]; // array to save the data int[] scoreData = new int[totalStudents]; for (int i = 0; i < totalStudents; i++) { // iterating over the loop System.out.print("Enter the Student's Name: "); // student name enter stNames[i] = input.next(); System.out.print("Enter the Student's Score: "); // prompt to enter the score scoreData[i] = input.nextInt(); }
  • 5. descendSort(stNames, scoreData); // calling the method System.out.println("The Order of the Students based on the Scores is : "); System.out.println(Arrays.toString(stNames)); // printing the result } public static void descendSort(String[] stNames, int[] scoreData) { // method to sort the data for (int i = scoreData.length - 1; i >= 1; i--) { // iterating over the loop String temp; // required initialisations int currentMax = scoreData[0]; int currentMaxIndex = 0; for (int j = 1; j <= i; j++) { // iterating over the loop to get the data if (currentMax > scoreData[j]) { // checking the conditions currentMax = scoreData[j]; currentMaxIndex = j; // assigning the values } } if (currentMaxIndex != i) { temp = stNames[currentMaxIndex]; stNames[currentMaxIndex] = stNames[i]; stNames[i] = temp; scoreData[currentMaxIndex] = scoreData[i]; scoreData[i] = currentMax; // assigning the values } } } } OUPTPUT : Enter the total number of Students: 3 Enter the Student's Name: John Enter the Student's Score: 98 Enter the Student's Name: Carter Enter the Student's Score: 58 Enter the Student's Name: MArk Enter the Student's Score: 65 The Order of the Students based on the Scores is : [John, MArk, Carter]
  • 6. Hope this is helpful.