Question: Create a program in c++ that will read the text file, input.txt, included in this assignment. The first line has an integer that shows how
Create a program in c++ that will read the text file, input.txt, included in this assignment. The first line has an integer that shows how many values are in the data file. Each line contains a force in Newtons. The force is written in Cartesian coordinates (12.3i 34.5j). The first number is is x component. The second number is the y component.
Your program will read the first integer to determine how many lines to read. For each line, your program should read in the two parts of the force into two float type variables. The program should calculate the magnitude and direction for each pair of numbers that it reads:
The program should then output the magnitude, a tab, the direction in radians, a tab, the x component, a tab, the y portion, and a newline character. The output can go to the screen, but it should also go to a file called output.txt.
Where there are any errors in the input, the program should skip that line, and write to the screen and to the output file: "Error reading line XX." where XX is the line number at which the error occurred. A missing number is an error. A missing i or j is also an error.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
