SlideShare a Scribd company logo
1 of 2
Download to read offline
Java:
a. The mean of a list of numbers is its arithmetic average. The median of a list is its middle value
when the values are placed in order. For example, if a list contains 1, 4, 7, 8, and 10, then the
mean is 6 and the median is 7. Write an application that allows you to enter five integers and
displays the values, their mean, and their median.
Save the file as MeanMedian.java.
b. Revise the MeanMedian class so that the user can enter any number of values up to 20. If the
list has an even number of values, the median is the numeric average of the values in the two
middle positions. Save the file as
MeanMedian2.java
Solution
Ans a):
import java.util.*;
import java.lang.*;
import java.io.*;
class MeanMedian
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan=new Scanner(System.in);
int arr[]=new int[5];
System.out.println("Enter the integers :"); //asking the user to enter 5 integers
for(int i=0;i<5;i++)
arr[i]=scan.nextInt();
int sum=0;
for(int i=0;i<5;i++)
sum=sum+arr[i];
int mean=sum/5; //calculating mean
int median=arr[2]; //calculating median
System.out.println("Integers entered by the user ");
for(int i=0;i<5;i++)
System.out.print(arr[i]+" "); //printing values entered by user
System.out.println();
System.out.println("Mean = "+mean); //printing mean
System.out.println("Median = "+median); //printing median
}
}
******OUTPUT******
Enter the integers :
1 4 7 8 10
Integers entered by the user
1 4 7 8 10
Mean = 6
Median = 7
******OUTPUT******
Ansb):
import java.util.*;
import java.lang.*;
import java.io.*;
class MeanMedian //class MeanMedian
{
public static void main (String[] args) throws java.lang.Exception
{
int sum=0; //variable to store the sum of values
int mean=0; //variable to store the mean of values
int median=0; //variable to store the median of values
Scanner scan=new Scanner(System.in);
System.out.println("Enter the number of values upto you want to enter,it must not be greater
than 20 :"); //asking the user for no.of values
int n=scan.nextInt(); //store size in n
int arr[]=new int[n]; //array to store integers
System.out.println("Enter the integers"); //asking the user to enter the integers
for(int i=0;i

More Related Content

Similar to Javaa. The mean of a list of numbers is its arithmetic average. T.pdf

Reading and writting
Reading and writtingReading and writting
Reading and writtingandreeamolnar
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notesGOKULKANNANMMECLECTC
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfarihantmum
 
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docxdorisc7
 
Average.javaimport java.util.Scanner;   import java.util.Arra.pdf
 Average.javaimport java.util.Scanner;   import java.util.Arra.pdf Average.javaimport java.util.Scanner;   import java.util.Arra.pdf
Average.javaimport java.util.Scanner;   import java.util.Arra.pdfanuragperipheral
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codepradesigali1
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3Abdul Haseeb
 
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfLab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfQalandarBux2
 
JAVAThe mean of a list of numbers is its arithmetic average. The .pdf
JAVAThe mean of a list of numbers is its arithmetic average. The .pdfJAVAThe mean of a list of numbers is its arithmetic average. The .pdf
JAVAThe mean of a list of numbers is its arithmetic average. The .pdfgopalk44
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfjanakim15
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docxdavinci54
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1sotlsoc
 

Similar to Javaa. The mean of a list of numbers is its arithmetic average. T.pdf (20)

07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
Reading and writting
Reading and writtingReading and writting
Reading and writting
 
Arrays and function basic c programming notes
Arrays and function basic c programming notesArrays and function basic c programming notes
Arrays and function basic c programming notes
 
Array BPK 2
Array BPK 2Array BPK 2
Array BPK 2
 
Unit 3
Unit 3 Unit 3
Unit 3
 
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdfWrite the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
Write the code above and the ones below in netbeans IDE 8.13. (Eli.pdf
 
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
 
Average.javaimport java.util.Scanner;   import java.util.Arra.pdf
 Average.javaimport java.util.Scanner;   import java.util.Arra.pdf Average.javaimport java.util.Scanner;   import java.util.Arra.pdf
Average.javaimport java.util.Scanner;   import java.util.Arra.pdf
 
Java final lab
Java final labJava final lab
Java final lab
 
CP Handout#9
CP Handout#9CP Handout#9
CP Handout#9
 
Array
ArrayArray
Array
 
Comp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source codeComp 122 lab 6 lab report and source code
Comp 122 lab 6 lab report and source code
 
C#.net
C#.netC#.net
C#.net
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
Python programming workshop session 3
 
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdfLab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
Lab02kdfshdfgajhdfgajhdfgajhdfgjhadgfasjhdgfjhasdgfjh.pdf
 
JAVAThe mean of a list of numbers is its arithmetic average. The .pdf
JAVAThe mean of a list of numbers is its arithmetic average. The .pdfJAVAThe mean of a list of numbers is its arithmetic average. The .pdf
JAVAThe mean of a list of numbers is its arithmetic average. The .pdf
 
data_structure (1).pptx
data_structure (1).pptxdata_structure (1).pptx
data_structure (1).pptx
 
C and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdfC and Data structure lab manual ECE (2).pdf
C and Data structure lab manual ECE (2).pdf
 
DS LAB RECORD.docx
DS LAB RECORD.docxDS LAB RECORD.docx
DS LAB RECORD.docx
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1
 

More from RAJATCHUGH12

Why is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdf
Why is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdfWhy is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdf
Why is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdfRAJATCHUGH12
 
What type of utility program is designed to automatically make dupli.pdf
What type of utility program is designed to automatically make dupli.pdfWhat type of utility program is designed to automatically make dupli.pdf
What type of utility program is designed to automatically make dupli.pdfRAJATCHUGH12
 
Which of the following is true of xylem conducts water up the plant .pdf
Which of the following is true of xylem conducts water up the plant .pdfWhich of the following is true of xylem conducts water up the plant .pdf
Which of the following is true of xylem conducts water up the plant .pdfRAJATCHUGH12
 
What are the essential elements to have in BRDR plansWhen is a d.pdf
What are the essential elements to have in BRDR plansWhen is a d.pdfWhat are the essential elements to have in BRDR plansWhen is a d.pdf
What are the essential elements to have in BRDR plansWhen is a d.pdfRAJATCHUGH12
 
What is the characteristic of the ring of quaternionsSolutionQ.pdf
What is the characteristic of the ring of quaternionsSolutionQ.pdfWhat is the characteristic of the ring of quaternionsSolutionQ.pdf
What is the characteristic of the ring of quaternionsSolutionQ.pdfRAJATCHUGH12
 
What are the four basic categories of output A. Instructions, pictu.pdf
What are the four basic categories of output  A. Instructions, pictu.pdfWhat are the four basic categories of output  A. Instructions, pictu.pdf
What are the four basic categories of output A. Instructions, pictu.pdfRAJATCHUGH12
 
vapour pressure equation The Clansius-Clapeyron relation relates the.pdf
vapour pressure equation The Clansius-Clapeyron relation relates the.pdfvapour pressure equation The Clansius-Clapeyron relation relates the.pdf
vapour pressure equation The Clansius-Clapeyron relation relates the.pdfRAJATCHUGH12
 
What is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdfWhat is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdfRAJATCHUGH12
 
What are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdfWhat are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdfRAJATCHUGH12
 
The Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdfThe Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdfRAJATCHUGH12
 
The distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdfThe distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdfRAJATCHUGH12
 
t hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdft hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdfRAJATCHUGH12
 
Rewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdfRewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdfRAJATCHUGH12
 
Need help answering these. Underline the correct answer The fundame.pdf
Need help answering these. Underline the correct answer  The fundame.pdfNeed help answering these. Underline the correct answer  The fundame.pdf
Need help answering these. Underline the correct answer The fundame.pdfRAJATCHUGH12
 
Origins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdfOrigins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdfRAJATCHUGH12
 
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfListings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfRAJATCHUGH12
 
In hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdfIn hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdfRAJATCHUGH12
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfRAJATCHUGH12
 
How does differ from evolution systematic Only cladistics traces e.pdf
How does  differ from evolution systematic  Only cladistics traces e.pdfHow does  differ from evolution systematic  Only cladistics traces e.pdf
How does differ from evolution systematic Only cladistics traces e.pdfRAJATCHUGH12
 
Giving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdfGiving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdfRAJATCHUGH12
 

More from RAJATCHUGH12 (20)

Why is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdf
Why is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdfWhy is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdf
Why is the T7 polymerase gene in E. coli strain BL21(DE3) under the .pdf
 
What type of utility program is designed to automatically make dupli.pdf
What type of utility program is designed to automatically make dupli.pdfWhat type of utility program is designed to automatically make dupli.pdf
What type of utility program is designed to automatically make dupli.pdf
 
Which of the following is true of xylem conducts water up the plant .pdf
Which of the following is true of xylem conducts water up the plant .pdfWhich of the following is true of xylem conducts water up the plant .pdf
Which of the following is true of xylem conducts water up the plant .pdf
 
What are the essential elements to have in BRDR plansWhen is a d.pdf
What are the essential elements to have in BRDR plansWhen is a d.pdfWhat are the essential elements to have in BRDR plansWhen is a d.pdf
What are the essential elements to have in BRDR plansWhen is a d.pdf
 
What is the characteristic of the ring of quaternionsSolutionQ.pdf
What is the characteristic of the ring of quaternionsSolutionQ.pdfWhat is the characteristic of the ring of quaternionsSolutionQ.pdf
What is the characteristic of the ring of quaternionsSolutionQ.pdf
 
What are the four basic categories of output A. Instructions, pictu.pdf
What are the four basic categories of output  A. Instructions, pictu.pdfWhat are the four basic categories of output  A. Instructions, pictu.pdf
What are the four basic categories of output A. Instructions, pictu.pdf
 
vapour pressure equation The Clansius-Clapeyron relation relates the.pdf
vapour pressure equation The Clansius-Clapeyron relation relates the.pdfvapour pressure equation The Clansius-Clapeyron relation relates the.pdf
vapour pressure equation The Clansius-Clapeyron relation relates the.pdf
 
What is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdfWhat is a test cross and why is it used What technology is essential.pdf
What is a test cross and why is it used What technology is essential.pdf
 
What are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdfWhat are homologous traits a. Traits that are functional and adapti.pdf
What are homologous traits a. Traits that are functional and adapti.pdf
 
The Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdfThe Vietnam War EraDiscuss the range of American responses to the .pdf
The Vietnam War EraDiscuss the range of American responses to the .pdf
 
The distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdfThe distance between two successive minimize of a transverse wave.pdf
The distance between two successive minimize of a transverse wave.pdf
 
t hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdft hether each of the following statements are true or false T F Stok.pdf
t hether each of the following statements are true or false T F Stok.pdf
 
Rewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdfRewrite the expression as an algebraic expression of x Rewrite the .pdf
Rewrite the expression as an algebraic expression of x Rewrite the .pdf
 
Need help answering these. Underline the correct answer The fundame.pdf
Need help answering these. Underline the correct answer  The fundame.pdfNeed help answering these. Underline the correct answer  The fundame.pdf
Need help answering these. Underline the correct answer The fundame.pdf
 
Origins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdfOrigins of psychologyWhen did it begin as a science 1879.pdf
Origins of psychologyWhen did it begin as a science 1879.pdf
 
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdfListings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
Listings for BinaryHeap.java and BinaryHeapTest.java are shown in th.pdf
 
In hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdfIn hypothesis testing, what is a Type I error Type II errorSol.pdf
In hypothesis testing, what is a Type I error Type II errorSol.pdf
 
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdfI am stuck on parts E and FExercise 1      NumberListTester.java.pdf
I am stuck on parts E and FExercise 1      NumberListTester.java.pdf
 
How does differ from evolution systematic Only cladistics traces e.pdf
How does  differ from evolution systematic  Only cladistics traces e.pdfHow does  differ from evolution systematic  Only cladistics traces e.pdf
How does differ from evolution systematic Only cladistics traces e.pdf
 
Giving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdfGiving your lawn more nutrients than it can absorb, can cause polluti.pdf
Giving your lawn more nutrients than it can absorb, can cause polluti.pdf
 

Recently uploaded

Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxneillewis46
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSean M. Fox
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptxPoojaSen20
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital ManagementMBA Assignment Experts
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...Nguyen Thanh Tu Collection
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesPooky Knightsmith
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportDenish Jangid
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppCeline George
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...Nguyen Thanh Tu Collection
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnershipsexpandedwebsite
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 

Recently uploaded (20)

ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading RoomSternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
Sternal Fractures & Dislocations - EMGuidewire Radiology Reading Room
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management8 Tips for Effective Working Capital Management
8 Tips for Effective Working Capital Management
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
24 ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH SỞ GIÁO DỤC HẢI DƯ...
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Trauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical PrinciplesTrauma-Informed Leadership - Five Practical Principles
Trauma-Informed Leadership - Five Practical Principles
 
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of TransportBasic Civil Engineering notes on Transportation Engineering & Modes of Transport
Basic Civil Engineering notes on Transportation Engineering & Modes of Transport
 
Improved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio AppImproved Approval Flow in Odoo 17 Studio App
Improved Approval Flow in Odoo 17 Studio App
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community PartnershipsSpring gala 2024 photo slideshow - Celebrating School-Community Partnerships
Spring gala 2024 photo slideshow - Celebrating School-Community Partnerships
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 

Javaa. The mean of a list of numbers is its arithmetic average. T.pdf

  • 1. Java: a. The mean of a list of numbers is its arithmetic average. The median of a list is its middle value when the values are placed in order. For example, if a list contains 1, 4, 7, 8, and 10, then the mean is 6 and the median is 7. Write an application that allows you to enter five integers and displays the values, their mean, and their median. Save the file as MeanMedian.java. b. Revise the MeanMedian class so that the user can enter any number of values up to 20. If the list has an even number of values, the median is the numeric average of the values in the two middle positions. Save the file as MeanMedian2.java Solution Ans a): import java.util.*; import java.lang.*; import java.io.*; class MeanMedian { public static void main (String[] args) throws java.lang.Exception { Scanner scan=new Scanner(System.in); int arr[]=new int[5]; System.out.println("Enter the integers :"); //asking the user to enter 5 integers for(int i=0;i<5;i++) arr[i]=scan.nextInt(); int sum=0; for(int i=0;i<5;i++) sum=sum+arr[i]; int mean=sum/5; //calculating mean int median=arr[2]; //calculating median System.out.println("Integers entered by the user "); for(int i=0;i<5;i++)
  • 2. System.out.print(arr[i]+" "); //printing values entered by user System.out.println(); System.out.println("Mean = "+mean); //printing mean System.out.println("Median = "+median); //printing median } } ******OUTPUT****** Enter the integers : 1 4 7 8 10 Integers entered by the user 1 4 7 8 10 Mean = 6 Median = 7 ******OUTPUT****** Ansb): import java.util.*; import java.lang.*; import java.io.*; class MeanMedian //class MeanMedian { public static void main (String[] args) throws java.lang.Exception { int sum=0; //variable to store the sum of values int mean=0; //variable to store the mean of values int median=0; //variable to store the median of values Scanner scan=new Scanner(System.in); System.out.println("Enter the number of values upto you want to enter,it must not be greater than 20 :"); //asking the user for no.of values int n=scan.nextInt(); //store size in n int arr[]=new int[n]; //array to store integers System.out.println("Enter the integers"); //asking the user to enter the integers for(int i=0;i