Using C++ what would be the program/code I would use to solve this problem Wrie
ID: 3865250 • Letter: U
Question
Using C++ what would be the program/code I would use to solve this problem
Explanation / Answer
The equation of a plane in the intercept form is
x/a + y/b + z/c = 1
where a, b , c are intercepts on x, y and z axis. a, b and c are non-zero
(You can get the equation from google. Example : http://www.solitaryroad.com/c401.html)
So the we need to write the program to accept a, b and c and find out 1/a, 1/b and 1/c and display the equation of the plane. The following code does that ...
If the answer helped, please don't forget to rate it. Thank you.
#include <iostream>
#include <iomanip> //used for formatting output with 3 decimal places
using namespace std;
int main()
{
double a, b, c;
double inv_a, inv_b, inv_c;
cout << "Enter x intercept i.e 'a' : ";
cin >> a;
cout << "Enter y intercept i.e 'b' : ";
cin >> b;
cout << "Enter z intercept i.e 'c' : ";
cin >> c;
//find the inverse of a , b and c
inv_a = 1/a;
inv_b = 1/b;
inv_c = 1/c;
cout << fixed << setprecision(3) ; //for displaying with 3 decimal points
cout << "The equation of the plane with intercepts a = " << a << ", b = " << b << ", c = " << c << " is " << endl;
cout << inv_a << " x ";
//decide whether to show + or - sign for y term
if(b < 0)
cout << " - " << -inv_b << " y ";
else
cout << " + " << inv_b << " y ";
//decide whether to show + or - sign for z term
if(c < 0)
cout << " - " << -inv_c << " z ";
else
cout << " + " << inv_c << " z ";
cout << " = 1" << endl;
}
output
Enter x intercept i.e 'a' : 4
Enter y intercept i.e 'b' : -5
Enter z intercept i.e 'c' : 3
The equation of the plane with intercepts a = 4.000, b = -5.000, c = 3.000 is
0.250 x - 0.200 y + 0.333 z = 1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.