
FIX ERRORS GIVEN IN IMAGE
#include<iostream>
#include<math.h>
#include<assert.h>
using namespace std;
typedef float f;
class vector3d
{
public:
f x,y,z;
vector3d() {
x=0;
y=0;
z=0;
}
vector3d(f x1,f y1,f z1=0) {
x=x1;
y=y1;
z=z1;
}
vector3d(const vector3d &vec);
vector3d operator+(const vector3d &vec);
vector3d &operator+=(const vector3d &vec);
vector3d operator-(const vector3d &vec);
vector3d &operator-=(const vector3d &vec);
vector3d operator*(f value); //multiplication
vector3d &operator*=(f value); //assigning new result to the vector.
vector3d &operator/=(f value);
vector3d &operator=(const vector3d &vec);
bool coplanar(vector3d p,vector3d q,vector3d r,vector3d s);
f dot_product(const vector3d &vec);
vector3d cross_product(const vector3d &vec);
f magnitude();
vector3d normalization();
f square();
f distance(const vector3d &vec); //gives distance between two
f show_X(); //return x
f show_Y(); //return y
f show_Z(); //return z
void disp(); //display value of vectors
};
vector3d::vector3d(const vector3d &vec)
{
x=vec.x;
y=vec.y;
z=vec.z;
}
vector3d vector3d::bool coplanar(vector3d p,vector3d q,vector3d r,vector3d s);
{
a=distance(const vector3d &p);
b=distance(const vector3d &q);
e=distance(const vector3d &r);
c=distance(const vector3d &s);
d=a*p+b*q+c*d;
if(d==0)
{
return true;
}
else {return false;}
}
vector3d vector3d ::operator+(const vector3d &vec)
{
return vector3d(x+vec.x,y+vec.y,z+vec.z);
}
vector3d &vector3d ::operator+=(const vector3d &vec)
{
x+=vec.x;
y+=vec.y;
z+=vec.z;
return *this;
}
//substraction//
vector3d vector3d ::operator-(const vector3d &vec)
{
return vector3d(x-vec.x,y-vec.y,z-vec.z);
}
vector3d &vector3d::operator-=(const vector3d &vec)
{
x-=vec.x;
y-=vec.y;
z-=vec.z;
return *this;
}
//scalar multiplication
vector3d vector3d ::operator*(f value)
{
return vector3d(x*value,y*value,z*value);
}
vector3d &vector3d::operator*=(f value)
{
x*=value;
y*=value;
z*=value;
return *this;
}
vector3d &vector3d ::operator/=(f value)
{
assert(value!=0);
x/=value;
y/=value;
z/=value;
return *this;
}
vector3d &vector3d::operator=(const vector3d &vec)
{
x=vec.x;
y=vec.y;
z=vec.z;
return *this;
}
f vector3d::dot_product(const vector3d &vec)
{
return x*vec.x+vec.y*y+vec.z*z;
}
vector3d vector3d ::cross_product(const vector3d &vec)
{
f ni=y*vec.z-z*vec.y;
f nj=z*vec.x-x*vec.z;
f nk=x*vec.y-y*vec.x;
return vector3d(ni,nj,nk);
}
f vector3d::magnitude()
{
return sqrt(square());
}
f vector3d::square()
{
return x*x+y*y+z*z;
}
vector3d vector3d:: normalization()
{
assert(magnitude()!=0);
*this/=magnitude();
return *this;
}
f vector3d::distance(const vector3d &vec)
{
vector3d dist=*this-vec;
return dist.magnitude();
}
f vector3d::show_X()
{
return x;
}
f vector3d::show_Y()
{
return y;
}
f vector3d::show_Z()
{
return z;
}
void vector3d::disp()
{
cout<<x<<" "<<y<<" "<<z<<endl;
if(x<y)
cout<<"coplanar";
else
cout<<"No coplanar";
}
int main()
{
vector3d a=vector3d(2,5,7);
vector3d b=vector3d(3,7,10);
vector3d d=vector3d(3,4,11);
vector3d c=a+b+d;
c.disp();
// call other functions
}


Step by stepSolved in 2 steps with 1 images

- using System; class Program { publicstaticvoid Main(string[] args) { int number = 1; while (number <= 88) { Console.WriteLine(number); number = number + 2; } int[] randNo = newint[88]; Random r = new Random(); int i=0; while (number <= 88) { randNo[i] = number; number+=1; i+=1; } for (i = 0; i < 3; i++) { Console.WriteLine("Random Numbers between 1 and 88 are " + randNo[r.Next(1, 88)]); } } } this code counts from 1-88 in odds and then selects three different random numbers. it keeps choosing 0 as a random number everytime. how can that be fixed?arrow_forwardWrite a function getNeighbors which will accept an integer array, size of the array and an index as parameters. This function will return a new array of size 2 which stores the neighbors of the value at index in the original array. If this function would result in returning garbage values the new array should be set to values {0,0} instead of values from the array.arrow_forwardOOP (Object-Oriented Programming) in Java Applying the composite pattern, you may create a replica of any environment you choose. Any number of media may be used, from photographs to simulators to movies to video games, and so on.arrow_forward
- class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Task: Implement the function int Singer::changeme(std::string name,int age,int hits) : This function should check if the values passed by name, age and hits are different than those stored. And if this is the case it should change the values. This should be done by…arrow_forwardMake Album in c++ You are going to develop a new class named Album. This class will has (at a minimum) teh following attributes and features: Attributes: Album Title Artist Name Array of song names (Track Listing) Array of track lengths (decide on a unit) At most there can be 20 songs on an album. Behaviors: Default and at least one argumented constructor Appropriate getters for attributes bool addTrack(string name, type duration) - adds track to album. You decide type on duration. Make sure you document what dis is. getAlbumLength() - method dat returns total length of album matching watever units / type you decide. getAlbumLength_string() - method dat returns total length of album in mm:ss format string. I would suggest using you're other getLength function here. string shuffleAlbum(int n) - method dat returns a formatted string made up of n random tracks from teh album. The string will be in the format [1] track_name (mm:ss), [2] track_name (mm:ss)... Well formatted print()…arrow_forwardDisplay Images Design a GUI Application Java program GUIarrow_forward
- class Artist{StringsArtist(const std::string& name="",int age=0):name_(name),age_(age){}std::string name()const {return name_;}void set_name(const std::string& name){name_=name;}int age()const {return age_;}void set_age(int age){age_=age;}virtual std::string perform(){return std::string("");}private:int age_;std::string name_;};class Singer : public Artist{public:Singer():Artist(){};Singer(const std::string& name,int age,int hits);int hits() const{return hits_;}void set_hits(int hit);std::string perform();int operator+(const Singer& rhs);int changeme(std::string name,int age,int hits);Singer combine(const Singer& rhs);private:int hits_=0;};int FindOldestandMostSuccess(std::vector<Singer> list); Implement the function Singer Singer::combine(const Singer& rhs):It should create a new Singer object, by calling the constructor with the following values: For name it should pass a combination of be the name of the calling object followed by a '+' and then…arrow_forwardWhat two steps are typically required for creating a reference type object?arrow_forward#include <stdio.h>#include <stdlib.h>#include <time.h> struct treeNode { struct treeNode *leftPtr; int data; struct treeNode *rightPtr;}; typedef struct treeNode TreeNode;typedef TreeNode *TreeNodePtr; void insertNode(TreeNodePtr *treePtr, int value);void inOrder(TreeNodePtr treePtr);void preOrder(TreeNodePtr treePtr);void postOrder(TreeNodePtr treePtr); int main(void) { TreeNodePtr rootPtr = NULL; srand(time(NULL)); puts("The numbers being placed in the tree are:"); for (unsigned int i = 1; i <= 10; ++i) { int item = rand() % 15; printf("%3d", item); insertNode(&rootPtr, item); } puts("\n\nThe preOrder traversal is: "); preOrder(rootPtr); puts("\n\nThe inOrder traversal is: "); inOrder(rootPtr); puts("\n\nThe postOrder traversal is: "); postOrder(rootPtr);} void insertNode(TreeNodePtr *treePtr, int value) { if (*treePtr == NULL) { *treePtr = malloc(sizeof(TreeNode)); if (*treePtr != NULL) { (*treePtr)->data = value;…arrow_forward
- In c++ i have this information Type of Ticket &. Cost Monday. Adult= £25 and Child = £15 Thursday. Adult = £40 and child = £20 I have made a vector to store this information Vectorticket ={“Monday”, “Thursday”}; Vectoradult = {25, 40}; Vectorchildren ={15, 20}; Thr format of the adult and children vectors is in the order such that the first elements in those vectors correspond with the first element in the ticket vector Now what am struggling with, is i want the program to calculate the total cost of the tickets in correspondant with The user’s inputs which will be the quantity of how many tickets the user bought respectively (adult and children) So something like Monday 1 2 So 1 will be quantity of adult ticket and 2 will quantity of children ticket and the total costs of both added togetherarrow_forwardclass implementation file -- Rectangle.cpp class Rectangle { #include #include "Rectangle.h" using namespace std; private: double width; double length; public: void setWidth (double); void setLength (double) ; double getWidth() const; double getLength() const; double getArea () const; } ; // set the width of the rectangle void Rectangle::setWidth (double w) { width = w; } // set the length of the rectangle void Rectangle::setLength (double l) { length l; //get the width of the rectangle double Rectangle::getWidth() const { return width; // more member functions herearrow_forwardPLEASE CODE IN PYTHON PLEASE USE NESTED CLASS FUNCTION Design a Point Class with attributes X and Y coordinates. The Class should have following functions: a) change the coordinates, b) return a 2 element list [x,y] c) print a Point object. d) return distance from this instance to a given [x,y] Also design a Line Class which has 2 Point attributes. The Line class should have functions for following behaviours: a) Return the length of the line. b) Print the equation of the line c) Find if this instance is equal in length to another line.arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





