C programming   Design a program that will record and display the distance between the rocket and the asteroids.   Problem description The rocket is traveling through space. Each asteroid has (x, y, z) position in space, where x, y, and z are the distances in kilometers from the rocket which is at 0,0,0. It will read a file asteroids.txt that represents the ID and location of each asteroid. The distance between the rocket and each asteroid is calculated based on the asteroid’s X, Y, Z position using the following formula. √(x2+y2+z2)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 3PP: (Data processing) Write a C++ program that allows the user to enter the following information from...
icon
Related questions
Question

C programming

 

Design a program that will record and display the distance between the rocket and the asteroids.

 

Problem description

The rocket is traveling through space. Each asteroid has (x, y, z) position in space, where x, y, and z are the distances in kilometers from the rocket which is at 0,0,0. It will read a file asteroids.txt that represents the ID and location of each asteroid. The distance between the rocket and each asteroid is calculated based on the asteroid’s X, Y, Z position using the following formula.

√(x2+y2+z2)

This program must be secure. The user puts their name and password, if both match the list you have in a text file on the disk (ID.txt), then the user gets access to the program. The program should allow 3 tries for name and password entry, if unsuccessful after 3 tries the program should print a message and terminate.

 

Program Input

-The name and password of the user.

- A file called ID.txt which contains names and passwords. Example below:

John 11234

Neil 12345

Alan 55321

Marc 73920

Buzz 95834

...

- Input to the program will be generated using a random generator for X, Y, and Z coordinate. The random generator will generate integer numbers between 1 and 1000. This data will be stored (write to a text file) in a text file called asteroids.txt. Assume the speed of asteroids is 25km/sec. There must be at least 5 asteroids’ data in the file.

The text data file asteroid.txt has the following format: only the numbers and IDs are in the file, not the heading (ID, X, Y, Z).

ID X Y Z
A 200 605 219
B 300 277 299
C 544 279 607
... ... ... ...

Program Output

- Calculating the distance between rocket and asteroid, and then write the following data to a file called distance.txt.

A 200 605 219 calculated distance
B 300 277 299 calculated distance
C 544 279 697 calculated distance
... ... ... ... ...

-Display an alarm message to screen with X, Y, and Z positions of asteroids within a distance of less than 500 km. Example below:

Warning!

Asteroid A at 200, 605, 219 km away.

Time to impact ?? seconds.

- Rank the asteroids in order from nearest to farthest and display the ranking with ID and distance. Example below:

Asteroid C: distance (must be the closest distance) 

Asteroid B: distance (must be the second closest distance)

...

 

Requirements

- Must assign information read from the file (.txt) to an array of structures then process the data.   

- Must use pointers to process an array of structures.

- The main function must do as little as possible other than calling other functions and passing parameters to those functions.

- Do not use global variables. Pass data back and forth via parameters or as return values.

- Use defined constants for ALL constants in your program

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Graphical User Interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr