Convert this code from java to C++ and explain the changes System.out.print(\"En
ID: 3589540 • Letter: C
Question
Convert this code from java to C++ and explain the changes
System.out.print("Enter 5 given points: ");
Convert this code from java to C++ and explain the changes
System.out.print("Enter 5 given points: ");
Scanner input = new Scanner(System.in); double[][] points = new double[5][2]; for (int i = 0; i < points.length; i++) { points[i][0] = input.nextDouble(); points[i][1] = input.nextDouble(); } MyRectangle2D r1 = MyRectangle2D.getRectangle(points); System.out.println("Center point: " + r1.getCenterP().toString()); System.out.println("width = " + r1.getWidth()); System.out.println("height = " + r1.getHeight()); } }Explanation / Answer
Hi
I have modified the code from java to c++.
#include <iostream>
using namespace std;
int main()
{
double points[5][2];
for (int i = 0; i < 5; i++) {
cin >> points[i][0];
cin >> points[i][1]
}
MyRectangle2D r1 = MyRectangle2D.getRectangle(points);
cout<<"Center point: "<< r1.getCenterP().toString()<<endl;
cout<<"width = "<< r1.getWidth()<<endl;
cout<<"height = "<< r1.getHeight()<<endl;
return 0;
}