SlideShare a Scribd company logo
1 of 2
Download to read offline
public class ImpPythTripEx
public static double[][] triples = new double[3][3];
public static void inputTwoSides(double sideAIn, double sideBIn, int rowIndex) {
triples[rowIndex][0] = sideAIn;
triples[rowIndex][1] = sideBIn;
triples[rowIndex][2] = Math.sqrt(Math.pow(sideAIn, 2) + Math.pow(sideBIn, 2));
}
public static void inputOneSideAndHyp(double sideAIn, double hypIn, int rowIndex) {
triples[rowIndex][0] = sideAIn;
triples[rowIndex][2] = hypIn;
triples[rowIndex][1] = Math.sqrt(Math.pow(hypIn,2) - Math.pow(sideAIn, 2));
}
public static void printTriple() {
for(int i=0; i<3; i++) {
System.out.print("PythTriple [ ");
for(int j=0; j<3; j++) {
if(j==0) {
System.out.print("sideA=");
}
if(j==1)
{ System.out.print("sideB=");
}
if(j==2)
{ System.out.print("hyp=");
}
System.out.print(String.format("%5.3f",triples[i][j]) + " ");
}
System.out.println("]"); } }
public static void main(String[] args) {
inputOneSideAndHyp(3,5,0);
inputOneSideAndHyp(1, Math.sqrt(2),1);
inputTwoSides(2, 3, 2);
printTriple();
}}
1.) Write a new version of the imperative programming exercise (involving Pythagorean Triples)
in C, with alterations that include
using an array of instances of a Pythagorean Triple struct instead of a two dimensional array
make sure the array is on the heap. Be sure to use the malloc function
***Please include screenshots of both the input and output! Thank you :)***

More Related Content

Similar to public class ImpPythTripEx public static double---- triples - new d.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
fashioncollection2
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3
sotlsoc
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
웅식 전
 
Using CUDA Within Mathematica
Using CUDA Within MathematicaUsing CUDA Within Mathematica
Using CUDA Within Mathematica
krasul
 
Using Cuda Within Mathematica
Using Cuda Within MathematicaUsing Cuda Within Mathematica
Using Cuda Within Mathematica
Shoaib Burq
 

Similar to public class ImpPythTripEx public static double---- triples - new d.pdf (20)

Gentle Introduction to Functional Programming
Gentle Introduction to Functional ProgrammingGentle Introduction to Functional Programming
Gentle Introduction to Functional Programming
 
write a program that given a list of 20 integers, sorts them accordi.pdf
write a program that given a list of 20 integers, sorts them accordi.pdfwrite a program that given a list of 20 integers, sorts them accordi.pdf
write a program that given a list of 20 integers, sorts them accordi.pdf
 
PRACTICAL COMPUTING
PRACTICAL COMPUTINGPRACTICAL COMPUTING
PRACTICAL COMPUTING
 
‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx‏‏chap6 list tuples.pptx
‏‏chap6 list tuples.pptx
 
types.pdf
types.pdftypes.pdf
types.pdf
 
Java binary subtraction
Java binary subtractionJava binary subtraction
Java binary subtraction
 
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
 
array2d.ppt
array2d.pptarray2d.ppt
array2d.ppt
 
Chapter 7.3
Chapter 7.3Chapter 7.3
Chapter 7.3
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
 
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
Flink Forward Berlin 2017: David Rodriguez - The Approximate Filter, Join, an...
 
11 1. multi-dimensional array eng
11 1. multi-dimensional array eng11 1. multi-dimensional array eng
11 1. multi-dimensional array eng
 
Array
ArrayArray
Array
 
C programs
C programsC programs
C programs
 
The Art of Clean Code
The Art of Clean CodeThe Art of Clean Code
The Art of Clean Code
 
Using CUDA Within Mathematica
Using CUDA Within MathematicaUsing CUDA Within Mathematica
Using CUDA Within Mathematica
 
Using Cuda Within Mathematica
Using Cuda Within MathematicaUsing Cuda Within Mathematica
Using Cuda Within Mathematica
 
Parameters
ParametersParameters
Parameters
 
Python basic
Python basic Python basic
Python basic
 
Huraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docxHuraira_waris_Assgnment_4.docx
Huraira_waris_Assgnment_4.docx
 

More from 3rdeyesolutions

public class EllipsoidList { private String list- private Array.pdf
public class EllipsoidList {     private String list-    private Array.pdfpublic class EllipsoidList {     private String list-    private Array.pdf
public class EllipsoidList { private String list- private Array.pdf
3rdeyesolutions
 

More from 3rdeyesolutions (20)

Python Use Request library only- Use the proper widgets - fonts and ba.pdf
Python Use Request library only- Use the proper widgets - fonts and ba.pdfPython Use Request library only- Use the proper widgets - fonts and ba.pdf
Python Use Request library only- Use the proper widgets - fonts and ba.pdf
 
Python Questions (pictured) G-1 What is the impact of the PATH environ.pdf
Python Questions (pictured) G-1 What is the impact of the PATH environ.pdfPython Questions (pictured) G-1 What is the impact of the PATH environ.pdf
Python Questions (pictured) G-1 What is the impact of the PATH environ.pdf
 
Python Questions (pictured) E-1 How can you replace the current proces.pdf
Python Questions (pictured) E-1 How can you replace the current proces.pdfPython Questions (pictured) E-1 How can you replace the current proces.pdf
Python Questions (pictured) E-1 How can you replace the current proces.pdf
 
Python Questions (pictured) F-1 Compiling the program in Step 1- how.pdf
Python Questions (pictured)   F-1 Compiling the program in Step 1- how.pdfPython Questions (pictured)   F-1 Compiling the program in Step 1- how.pdf
Python Questions (pictured) F-1 Compiling the program in Step 1- how.pdf
 
Python Questions (pictured) D-1 What happens to the file -etc-zzz when.pdf
Python Questions (pictured) D-1 What happens to the file -etc-zzz when.pdfPython Questions (pictured) D-1 What happens to the file -etc-zzz when.pdf
Python Questions (pictured) D-1 What happens to the file -etc-zzz when.pdf
 
python program ile Handling- Collection - given the file currency-csv.pdf
python program ile Handling- Collection - given the file currency-csv.pdfpython program ile Handling- Collection - given the file currency-csv.pdf
python program ile Handling- Collection - given the file currency-csv.pdf
 
Python is a popular programming language used in a wide range of field.pdf
Python is a popular programming language used in a wide range of field.pdfPython is a popular programming language used in a wide range of field.pdf
Python is a popular programming language used in a wide range of field.pdf
 
PYTHON CODING I have to create a Red vs Blue game in python with a GUI.pdf
PYTHON CODING I have to create a Red vs Blue game in python with a GUI.pdfPYTHON CODING I have to create a Red vs Blue game in python with a GUI.pdf
PYTHON CODING I have to create a Red vs Blue game in python with a GUI.pdf
 
python code plz Task 2 1- Create a list with the digits in your studen.pdf
python code plz Task 2 1- Create a list with the digits in your studen.pdfpython code plz Task 2 1- Create a list with the digits in your studen.pdf
python code plz Task 2 1- Create a list with the digits in your studen.pdf
 
PYTHON - time and space complexity for the next function- def some_fun.pdf
PYTHON - time and space complexity for the next function- def some_fun.pdfPYTHON - time and space complexity for the next function- def some_fun.pdf
PYTHON - time and space complexity for the next function- def some_fun.pdf
 
Python - Explain the concept- and why you found it interesting- How w.pdf
Python -  Explain the concept- and why you found it interesting- How w.pdfPython -  Explain the concept- and why you found it interesting- How w.pdf
Python - Explain the concept- and why you found it interesting- How w.pdf
 
Put the steps of endochondral ossification in the correct order- Your.pdf
Put the steps of endochondral ossification in the correct order- Your.pdfPut the steps of endochondral ossification in the correct order- Your.pdf
Put the steps of endochondral ossification in the correct order- Your.pdf
 
Put the events of HIV infection in the correct order- HIV fuses to the.pdf
Put the events of HIV infection in the correct order- HIV fuses to the.pdfPut the events of HIV infection in the correct order- HIV fuses to the.pdf
Put the events of HIV infection in the correct order- HIV fuses to the.pdf
 
Put the following events in the proper order of occurrence when RIK pa.pdf
Put the following events in the proper order of occurrence when RIK pa.pdfPut the following events in the proper order of occurrence when RIK pa.pdf
Put the following events in the proper order of occurrence when RIK pa.pdf
 
Put an I if the term refers to Innate Immunity Put an A if the term re.pdf
Put an I if the term refers to Innate Immunity Put an A if the term re.pdfPut an I if the term refers to Innate Immunity Put an A if the term re.pdf
Put an I if the term refers to Innate Immunity Put an A if the term re.pdf
 
Pure tone averages (PTAs) give us information about- how well a person.pdf
Pure tone averages (PTAs) give us information about- how well a person.pdfPure tone averages (PTAs) give us information about- how well a person.pdf
Pure tone averages (PTAs) give us information about- how well a person.pdf
 
public class EllipsoidList { private String list- private Array.pdf
public class EllipsoidList {     private String list-    private Array.pdfpublic class EllipsoidList {     private String list-    private Array.pdf
public class EllipsoidList { private String list- private Array.pdf
 
Public Administration -what kind of challenges does the Department of.pdf
Public Administration -what kind of challenges does the Department of.pdfPublic Administration -what kind of challenges does the Department of.pdf
Public Administration -what kind of challenges does the Department of.pdf
 
public class Integenthalysis public static doumle analyreints(iet max-.pdf
public class Integenthalysis public static doumle analyreints(iet max-.pdfpublic class Integenthalysis public static doumle analyreints(iet max-.pdf
public class Integenthalysis public static doumle analyreints(iet max-.pdf
 
PT ANRJ issues a IDR 450 million IPO priced at IDR 130 per share- and.pdf
PT ANRJ  issues a IDR 450 million IPO priced at IDR 130 per share- and.pdfPT ANRJ  issues a IDR 450 million IPO priced at IDR 130 per share- and.pdf
PT ANRJ issues a IDR 450 million IPO priced at IDR 130 per share- and.pdf
 

Recently uploaded

Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 

public class ImpPythTripEx public static double---- triples - new d.pdf

  • 1. public class ImpPythTripEx public static double[][] triples = new double[3][3]; public static void inputTwoSides(double sideAIn, double sideBIn, int rowIndex) { triples[rowIndex][0] = sideAIn; triples[rowIndex][1] = sideBIn; triples[rowIndex][2] = Math.sqrt(Math.pow(sideAIn, 2) + Math.pow(sideBIn, 2)); } public static void inputOneSideAndHyp(double sideAIn, double hypIn, int rowIndex) { triples[rowIndex][0] = sideAIn; triples[rowIndex][2] = hypIn; triples[rowIndex][1] = Math.sqrt(Math.pow(hypIn,2) - Math.pow(sideAIn, 2)); } public static void printTriple() { for(int i=0; i<3; i++) { System.out.print("PythTriple [ "); for(int j=0; j<3; j++) { if(j==0) { System.out.print("sideA="); } if(j==1) { System.out.print("sideB="); } if(j==2) { System.out.print("hyp=");
  • 2. } System.out.print(String.format("%5.3f",triples[i][j]) + " "); } System.out.println("]"); } } public static void main(String[] args) { inputOneSideAndHyp(3,5,0); inputOneSideAndHyp(1, Math.sqrt(2),1); inputTwoSides(2, 3, 2); printTriple(); }} 1.) Write a new version of the imperative programming exercise (involving Pythagorean Triples) in C, with alterations that include using an array of instances of a Pythagorean Triple struct instead of a two dimensional array make sure the array is on the heap. Be sure to use the malloc function ***Please include screenshots of both the input and output! Thank you :)***