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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started