Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please put in C language programming. Project Description: In this project, you will develop a calculator for vectors. Your program will ask the user to

Please put in C language programming.
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Project Description: In this project, you will develop a calculator for vectors. Your program will ask the user to read in two vectors X and Y. The user will first enter the length of both vector (both vectors have the same length) and followed by each element of the vector. The maximum vector length is 10. For example, a sample input is as follows: Enter the vector length (maximum 10): 4 Enter vector X: 2.342 -3.45 S 12.33 Enter vector Y: 4.5 -5 0 10.788 Then your program will display a menu of options and ask the user to choose one of the options repeatedly until the user chooses the exit (option 8). Below is a list of options and their descriptions: Option Description Display vector (precision is 2) Calculate the sum of all the elements of the vector Calculate the length of the vector Display negation of the vector Display addition of vectors X and Y Display subtraction of vectors X and Y Calculate the inner-product of vectors X and Y Exit the program Option 1: This option simply displays both vectors in the following required format with precision 2 Separate the elements by commas followed by a single space. Sample output: X: (2.34, -3.45, 5.00, 12.33) Y: (4.50, -5.00, 0.00, 10.79) Option 2: This option calculates and displays the sum of all the elements of each vector. Sample output: Sum of elements of X is 16.22 Sum of elements of Y is 10.29 Option3: This option calculates and displays the length of each vector, i.e., square root of the sum of square of each element in the vector. The length of the vector X = 2+()2 = {x} + xz + ... + x Sample output: The length of X is 13.94 The length of Y is 12.71 ..-. y). Option 4 IrY- O y then negation of Y gives - Sample output -X1 -2.34, 3.45, -5.00 -12.33) -Y -4.50, 5.00, 0.00, -10.79) Option 5 This option calculates and displays X+Y, element by element. Sample output: X+Y: (6.84, -8.45, 5.00, 23.12) Option 6 This option calculates and displays X - Y, clement by element Sample output: X-Y: (-2.16, 1.55, 5.00, 1.54) Option 7 The inner product of two vectors X and Y is calculated as Sample output: The inner product of X and Y is 160.81 a Option 8: Exit the program. Error Checking: Your program should check thoroughly for relevant errors. Upon encountering an error. the program should report an informative error message and handle the error accordingly. Certain errors are recoverable errors. Upon encountering such errors, the program should output a meaningful error message and continue the program, for example, if an invalid option is entered Certain errors are fatal errors. Upon encountering fatal errors, the program should output a meaningful error message and exit. For example, if the length of the vector is not a positive integer or the length exceeds the maximum length. Project Requirements: The project should be well-documented (comments) and properly indented. Title block is required (Name, project number, project description). Your code should be clear and well organized. Define of your own functions is highly recommended, but not required. Submission Requirements: When submitting your project, please submit an archive of your entire project directory. Use LIMITATIONS.txt to document anything that could not be fully completed or debugged. No late submissions will be accepted. Grading Guidelines: Correctness under normal input Error handling (both recoverable and fatal) Documentations and Indentations 80% 10% 10% Project Description: In this project, you will develop a calculator for vectors. Your program will ask the user to read in two vectors X and Y. The user will first enter the length of both vector (both vector have the same length) and followed by cach element of the vector. The maximum vector length is 10. For example, a sample input is as follows: Enter the vector length (maximum 10): 4 Enter vector X: 2.342 -3.45 S 12.33 Enter vector Y: 4.5-5 0 10.788 Then your program will display a menu of options and ask the user to choose one of the options repeatedly until the user chooses the exit (option 8). Below is a list of options and their descriptions: Option Description Display vector (precision is 2) Calculate the sum of all the elements of the vector Calculate the length of the vector Display negation of the vector Display addition of vectors X and Y Display subtraction of vectors X and Y Calculate the inner-product of vectors X and Exit the program Option 1 : This option simply displays both vectors in the following required format with precision 2. Separate the elements by commas followed by a single space. Sample output: X: (2.34, -3.45, 5.00, 12.33) Y: (4.50, -5.00, 0.00, 10.79) Option 2: This option calculates and displays the sum of all the elements of each vector. Sample output: Sum of elements of X is 16.22 Sum of elements of Y is 10.29 Option3: This option calculates and displays the length of each vector, i.e., square root of the sum of square of each element in the vector. The length of the vector X=27=2(X.)2=vx} + x + ... + x Sample output: The length of x is 13.94 The length of Y is 12.71 Option 4 If Y = (y1, y2, y....yo), then negation of Y gives (-71,-y2, -Y3..... -Y). Sample output: -X: (-2.34, 3.45, -5.00, -12.33) -Y: (-4.50, 5.00, 0.00, -10.79) Option 5 This option calculates and displays X+Y, element by element. Sample output: X+Y: (6.84, -8.45, 5.00, 23.12) Option 6 This option calculates and displays X - Y, element by element. Sample output: X-Y: (-2.16, 1.55, 5.00, 1.54) Option 7 The inner product of two vectors X and Y is calculated as 2n=Xiyi Sample output: The inner product of X and Y is 160.81 Option 8: Exit the program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions