SlideShare une entreprise Scribd logo
1  sur  3
Exercise #1:
Write a program that declares a two-dimensional array named myFancyArray of the type double.
Initialize the array to the following values:
23 14.12 17 85.99
6.06 13 1100 0
36.36 90.09 3.145 5.4
1. Create a function that will return the sum of column three. Output this result.
2. Create a function that finds the ceiling of each value in the array.
3. Create a function that will use a nested loop to display all the elements in the array to the
screen.
Solution
in java
package s1;
class extra {
public static double sum(double a, double b, double c) {
return a + b + c;
}
public static void ceiling(double a[][]) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[a.length - 1].length; j++) {
System.out.print(Math.ceil(a[i][j]) + "t");
}
System.out.println("");
}
}
public static void print(double a[][]) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[a.length - 1].length; j++) {
System.out.print(a[i][j] + "t");
}
System.out.println("");
}
}
public static void main(String[] args) {
double[][] myFancyArray = {{23, 14.12, 17, 85.99}, {6.06, 13, 1100, 0}, {36.36, 90.09, 3.145,
5.4}};
System.out.println("Sum="+sum( myFancyArray[0][0],myFancyArray[1][1],
myFancyArray[2][2]));
System.out.println("ceiling");
ceiling(myFancyArray);
System.out.println("print");
print(myFancyArray);
}
}
output
run:
Sum=39.145
ceiling
23.0Â Â 15.0Â Â 17.0Â Â 86.0
7.0Â Â 13.0Â Â 1100.0Â Â 0.0
37.0Â Â 91.0Â Â 4.0Â Â 6.0
print
23.0Â Â 14.12Â Â 17.0Â Â 85.99
6.06Â Â 13.0Â Â 1100.0Â Â 0.0
36.36Â Â 90.09Â Â 3.145Â Â 5.4
BUILD SUCCESSFUL (total time: 0 seconds)
Exercise #1- Write a program that declares a two-dimensional array nam.docx

Contenu connexe

Similaire à Exercise #1- Write a program that declares a two-dimensional array nam.docx

Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxTseChris
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALPrabhu D
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iiiNiraj Bharambe
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdfanupamfootwear
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
Java Programs
Java ProgramsJava Programs
Java Programsvvpadhu
 
two dimensional array
two dimensional array two dimensional array
two dimensional array Tariq Aziz
 
Java Questions
Java QuestionsJava Questions
Java Questionsbindur87
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
Assignment Java Programming 2
Assignment Java Programming 2Assignment Java Programming 2
Assignment Java Programming 2Kaela Johnson
 

Similaire à Exercise #1- Write a program that declares a two-dimensional array nam.docx (20)

Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptx
 
CP Handout#9
CP Handout#9CP Handout#9
CP Handout#9
 
JAVAPGMS.docx
JAVAPGMS.docxJAVAPGMS.docx
JAVAPGMS.docx
 
Cs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUALCs2312 OOPS LAB MANUAL
Cs2312 OOPS LAB MANUAL
 
Java practical
Java practicalJava practical
Java practical
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 Problem1 java codeimport java.util.Scanner; Java code to pr.pdf Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
Problem1 java codeimport java.util.Scanner; Java code to pr.pdf
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
Lecture 1 mte 407
Lecture 1 mte 407Lecture 1 mte 407
Lecture 1 mte 407
 
two dimensional array
two dimensional array two dimensional array
two dimensional array
 
White box-sol
White box-solWhite box-sol
White box-sol
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
Container adapters
Container adaptersContainer adapters
Container adapters
 
Java Questions
Java QuestionsJava Questions
Java Questions
 
JavaProgrammingManual
JavaProgrammingManualJavaProgrammingManual
JavaProgrammingManual
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
Assignment Java Programming 2
Assignment Java Programming 2Assignment Java Programming 2
Assignment Java Programming 2
 

Plus de vtuan3

Arrange the following elements from greatest to least tendency to acce.docx
Arrange the following elements from greatest to least tendency to acce.docxArrange the following elements from greatest to least tendency to acce.docx
Arrange the following elements from greatest to least tendency to acce.docxvtuan3
 
Arrange the elution sequence of the following compounds by using rever.docx
Arrange the elution sequence of the following compounds by using rever.docxArrange the elution sequence of the following compounds by using rever.docx
Arrange the elution sequence of the following compounds by using rever.docxvtuan3
 
Are you surprised by the variety and range of issues addressed by the.docx
Are you surprised by the variety and range of issues addressed by the.docxAre you surprised by the variety and range of issues addressed by the.docx
Are you surprised by the variety and range of issues addressed by the.docxvtuan3
 
Are there ethical considerations we should consider during the the ent.docx
Are there ethical considerations we should consider during the the ent.docxAre there ethical considerations we should consider during the the ent.docx
Are there ethical considerations we should consider during the the ent.docxvtuan3
 
AP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docx
AP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docxAP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docx
AP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docxvtuan3
 
answers- 22- H lysine- You do not have to write them all out- ow many.docx
answers- 22- H lysine- You do not have to write them all out- ow many.docxanswers- 22- H lysine- You do not have to write them all out- ow many.docx
answers- 22- H lysine- You do not have to write them all out- ow many.docxvtuan3
 
Answer was D) but I need detailed help with steps as to how - On Janua.docx
Answer was D) but I need detailed help with steps as to how - On Janua.docxAnswer was D) but I need detailed help with steps as to how - On Janua.docx
Answer was D) but I need detailed help with steps as to how - On Janua.docxvtuan3
 
Answer the below in your own words- What were the reasons for the deco.docx
Answer the below in your own words- What were the reasons for the deco.docxAnswer the below in your own words- What were the reasons for the deco.docx
Answer the below in your own words- What were the reasons for the deco.docxvtuan3
 
Answer in your own words- Would you agree with Karl Marx in saying tha.docx
Answer in your own words- Would you agree with Karl Marx in saying tha.docxAnswer in your own words- Would you agree with Karl Marx in saying tha.docx
Answer in your own words- Would you agree with Karl Marx in saying tha.docxvtuan3
 
Analyze the role of credit rationing in both a developed country and a.docx
Analyze the role of credit rationing in both a developed country and a.docxAnalyze the role of credit rationing in both a developed country and a.docx
Analyze the role of credit rationing in both a developed country and a.docxvtuan3
 
Annual worth calculations require equal life alternatives- T or F - An.docx
Annual worth calculations require equal life alternatives- T or F - An.docxAnnual worth calculations require equal life alternatives- T or F - An.docx
Annual worth calculations require equal life alternatives- T or F - An.docxvtuan3
 
Annual editions of journal What will social media look like in the fu.docx
Annual editions of journal  What will social media look like in the fu.docxAnnual editions of journal  What will social media look like in the fu.docx
Annual editions of journal What will social media look like in the fu.docxvtuan3
 
An unknown mixture of ions was treated with hydrochloric acid resultin.docx
An unknown mixture of ions was treated with hydrochloric acid resultin.docxAn unknown mixture of ions was treated with hydrochloric acid resultin.docx
An unknown mixture of ions was treated with hydrochloric acid resultin.docxvtuan3
 
Analyze the role cryptographic algorithms play and explain how these a.docx
Analyze the role cryptographic algorithms play and explain how these a.docxAnalyze the role cryptographic algorithms play and explain how these a.docx
Analyze the role cryptographic algorithms play and explain how these a.docxvtuan3
 
Analyze and determine which sector- public or private- has greater ins.docx
Analyze and determine which sector- public or private- has greater ins.docxAnalyze and determine which sector- public or private- has greater ins.docx
Analyze and determine which sector- public or private- has greater ins.docxvtuan3
 
an102 Tollowing infrared spectra- Some examples of functional groups a.docx
an102 Tollowing infrared spectra- Some examples of functional groups a.docxan102 Tollowing infrared spectra- Some examples of functional groups a.docx
an102 Tollowing infrared spectra- Some examples of functional groups a.docxvtuan3
 
An unknown compound is one of the four compounds shown below- It is an.docx
An unknown compound is one of the four compounds shown below- It is an.docxAn unknown compound is one of the four compounds shown below- It is an.docx
An unknown compound is one of the four compounds shown below- It is an.docxvtuan3
 
Analyze the types of informal and formal communication in organization.docx
Analyze the types of informal and formal communication in organization.docxAnalyze the types of informal and formal communication in organization.docx
Analyze the types of informal and formal communication in organization.docxvtuan3
 
Encapsulation process- Explain this process giving specific detail at.docx
Encapsulation process- Explain this process giving specific detail at.docxEncapsulation process- Explain this process giving specific detail at.docx
Encapsulation process- Explain this process giving specific detail at.docxvtuan3
 
Elijah Murphy studied voice- opera- and Jewish liturgical music at the.docx
Elijah Murphy studied voice- opera- and Jewish liturgical music at the.docxElijah Murphy studied voice- opera- and Jewish liturgical music at the.docx
Elijah Murphy studied voice- opera- and Jewish liturgical music at the.docxvtuan3
 

Plus de vtuan3 (20)

Arrange the following elements from greatest to least tendency to acce.docx
Arrange the following elements from greatest to least tendency to acce.docxArrange the following elements from greatest to least tendency to acce.docx
Arrange the following elements from greatest to least tendency to acce.docx
 
Arrange the elution sequence of the following compounds by using rever.docx
Arrange the elution sequence of the following compounds by using rever.docxArrange the elution sequence of the following compounds by using rever.docx
Arrange the elution sequence of the following compounds by using rever.docx
 
Are you surprised by the variety and range of issues addressed by the.docx
Are you surprised by the variety and range of issues addressed by the.docxAre you surprised by the variety and range of issues addressed by the.docx
Are you surprised by the variety and range of issues addressed by the.docx
 
Are there ethical considerations we should consider during the the ent.docx
Are there ethical considerations we should consider during the the ent.docxAre there ethical considerations we should consider during the the ent.docx
Are there ethical considerations we should consider during the the ent.docx
 
AP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docx
AP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docxAP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docx
AP Chemistry Review Questions Integrating Content- Inquiry and Reasoni.docx
 
answers- 22- H lysine- You do not have to write them all out- ow many.docx
answers- 22- H lysine- You do not have to write them all out- ow many.docxanswers- 22- H lysine- You do not have to write them all out- ow many.docx
answers- 22- H lysine- You do not have to write them all out- ow many.docx
 
Answer was D) but I need detailed help with steps as to how - On Janua.docx
Answer was D) but I need detailed help with steps as to how - On Janua.docxAnswer was D) but I need detailed help with steps as to how - On Janua.docx
Answer was D) but I need detailed help with steps as to how - On Janua.docx
 
Answer the below in your own words- What were the reasons for the deco.docx
Answer the below in your own words- What were the reasons for the deco.docxAnswer the below in your own words- What were the reasons for the deco.docx
Answer the below in your own words- What were the reasons for the deco.docx
 
Answer in your own words- Would you agree with Karl Marx in saying tha.docx
Answer in your own words- Would you agree with Karl Marx in saying tha.docxAnswer in your own words- Would you agree with Karl Marx in saying tha.docx
Answer in your own words- Would you agree with Karl Marx in saying tha.docx
 
Analyze the role of credit rationing in both a developed country and a.docx
Analyze the role of credit rationing in both a developed country and a.docxAnalyze the role of credit rationing in both a developed country and a.docx
Analyze the role of credit rationing in both a developed country and a.docx
 
Annual worth calculations require equal life alternatives- T or F - An.docx
Annual worth calculations require equal life alternatives- T or F - An.docxAnnual worth calculations require equal life alternatives- T or F - An.docx
Annual worth calculations require equal life alternatives- T or F - An.docx
 
Annual editions of journal What will social media look like in the fu.docx
Annual editions of journal  What will social media look like in the fu.docxAnnual editions of journal  What will social media look like in the fu.docx
Annual editions of journal What will social media look like in the fu.docx
 
An unknown mixture of ions was treated with hydrochloric acid resultin.docx
An unknown mixture of ions was treated with hydrochloric acid resultin.docxAn unknown mixture of ions was treated with hydrochloric acid resultin.docx
An unknown mixture of ions was treated with hydrochloric acid resultin.docx
 
Analyze the role cryptographic algorithms play and explain how these a.docx
Analyze the role cryptographic algorithms play and explain how these a.docxAnalyze the role cryptographic algorithms play and explain how these a.docx
Analyze the role cryptographic algorithms play and explain how these a.docx
 
Analyze and determine which sector- public or private- has greater ins.docx
Analyze and determine which sector- public or private- has greater ins.docxAnalyze and determine which sector- public or private- has greater ins.docx
Analyze and determine which sector- public or private- has greater ins.docx
 
an102 Tollowing infrared spectra- Some examples of functional groups a.docx
an102 Tollowing infrared spectra- Some examples of functional groups a.docxan102 Tollowing infrared spectra- Some examples of functional groups a.docx
an102 Tollowing infrared spectra- Some examples of functional groups a.docx
 
An unknown compound is one of the four compounds shown below- It is an.docx
An unknown compound is one of the four compounds shown below- It is an.docxAn unknown compound is one of the four compounds shown below- It is an.docx
An unknown compound is one of the four compounds shown below- It is an.docx
 
Analyze the types of informal and formal communication in organization.docx
Analyze the types of informal and formal communication in organization.docxAnalyze the types of informal and formal communication in organization.docx
Analyze the types of informal and formal communication in organization.docx
 
Encapsulation process- Explain this process giving specific detail at.docx
Encapsulation process- Explain this process giving specific detail at.docxEncapsulation process- Explain this process giving specific detail at.docx
Encapsulation process- Explain this process giving specific detail at.docx
 
Elijah Murphy studied voice- opera- and Jewish liturgical music at the.docx
Elijah Murphy studied voice- opera- and Jewish liturgical music at the.docxElijah Murphy studied voice- opera- and Jewish liturgical music at the.docx
Elijah Murphy studied voice- opera- and Jewish liturgical music at the.docx
 

Dernier

Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxruthvilladarez
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxJanEmmanBrigoli
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 

Dernier (20)

Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
TEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docxTEACHER REFLECTION FORM (NEW SET........).docx
TEACHER REFLECTION FORM (NEW SET........).docx
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Millenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptxMillenials and Fillennials (Ethical Challenge and Responses).pptx
Millenials and Fillennials (Ethical Challenge and Responses).pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 

Exercise #1- Write a program that declares a two-dimensional array nam.docx

  • 1. Exercise #1: Write a program that declares a two-dimensional array named myFancyArray of the type double. Initialize the array to the following values: 23 14.12 17 85.99 6.06 13 1100 0 36.36 90.09 3.145 5.4 1. Create a function that will return the sum of column three. Output this result. 2. Create a function that finds the ceiling of each value in the array. 3. Create a function that will use a nested loop to display all the elements in the array to the screen. Solution in java package s1; class extra { public static double sum(double a, double b, double c) { return a + b + c; } public static void ceiling(double a[][]) { for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[a.length - 1].length; j++) { System.out.print(Math.ceil(a[i][j]) + "t"); } System.out.println(""); } }
  • 2. public static void print(double a[][]) { for (int i = 0; i < a.length; i++) { for (int j = 0; j < a[a.length - 1].length; j++) { System.out.print(a[i][j] + "t"); } System.out.println(""); } } public static void main(String[] args) { double[][] myFancyArray = {{23, 14.12, 17, 85.99}, {6.06, 13, 1100, 0}, {36.36, 90.09, 3.145, 5.4}}; System.out.println("Sum="+sum( myFancyArray[0][0],myFancyArray[1][1], myFancyArray[2][2])); System.out.println("ceiling"); ceiling(myFancyArray); System.out.println("print"); print(myFancyArray); } } output run: Sum=39.145 ceiling 23.0Â Â 15.0Â Â 17.0Â Â 86.0 7.0Â Â 13.0Â Â 1100.0Â Â 0.0 37.0Â Â 91.0Â Â 4.0Â Â 6.0 print 23.0Â Â 14.12Â Â 17.0Â Â 85.99 6.06Â Â 13.0Â Â 1100.0Â Â 0.0 36.36Â Â 90.09Â Â 3.145Â Â 5.4 BUILD SUCCESSFUL (total time: 0 seconds)