Question: I need the real code for this program: (convert pseudocode to C++) Start Program Type Vector is Structure Defined x is double variable y is
I need the real code for this program: (convert pseudocode to C++)
Start Program
Type Vector is Structure Defined
x is double variable
y is double variable
End Vector Type
Function Prototype Get Choice(parameters: int &)
Function Prototype vAddition (parameters: vector v1, vector v2, vector &v3)
Function Prototype vSubstract(parameters: vector v1, vector v2, vector &v3)
Function Prototype sMult(parameters: int k, vector v, vector &v3)
Function Prototype sProduct (parameters: vector v1, vector v2)
Function Prototype getMag (parameter: vector v)
Function Prototype vPrint (parameter: vector v)
Start Main
Initialize K to 10
Initialize Vector 1 to (4,9)
Initialize Vector 2 to (3,-1)
Call function getchoice(argument: choice)
Start do while loop
while choice is not equal to 0
start switch cases
start case 1
call vaddition(arguments: v1, v2, v3)
call vprint(argument: v3)
end case 1
start case 2
call vsubtract(arguments: v1, v2, v3)
call vprint(argument: v3)
end case 2
start case 3
call getvchoice(argument: vchoice)
if choice = 1
call sMult(arguments: k, v1, v3 )
call sPrint(argument: v3)
end if
if choice = 2
call sMult(arguments: k, v2, v3)
call sPrint(argument: v3)
end if
end Case 3
start case 4
call sProduct (arguments: v1,v2)
end case 4
start case 5
getvchoice(argument: vchoice)
if vchoice = 1
call vMag(argument: v1)
if vchoice = 2
call vMag(argument: v2)
end case 5
Call getchoice(argument: choice)
End do while loop
end main
void getchoice(parameters: int &choice)
choose an option
1. Add Two Vectors
2. Subtract Two Vectors
3. Scalar Multiplication
4. Scalar Product
5. Calculate Vector Magnitude
0. Exit Program
Obtain the user input
while choice < 0 or choice > 5
1. Add Two Vectors
2. Subtract Two Vectors
3. Scalar Multiplication
4. Scalar Product
5. Calculate Vector Magnitude
0. Exit Program
Obtain the User Input
void getvchoice(parameters: int &vchoice)
start do
choose the vector you would like to multiply
1. vector v1
2. vector v2
obtain user input
while vchoice is not equal to 1 and vchoice is not equal to 2
end do/while
void vprint(parameter: vector v)
The result is (v.x, v.y)
void vAddition(parameters: vector v1, vector v2, vector &v3)
v3.x = v1.x + v2.x
v3.x = v1.x + v2.x
void vSubtract(parameters: vector v1, vector v2, vector &v3)
v3.x = v1.x - v2.x
v3.y = v1.y - v2.y
void sMult(parameters: int k, vector v, vector &v3)
v3.x = k*v.x
v3.y = k*v.y
void sProduct(parameters: vector v1, vector v2)
The Scalar Product is: v1.x*v2.x + v1.y*v2.y
void getMag(parameters: vector v)
The magnitude of the vector is the square root of: (v.x * v.x + v.y * v.y)
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
