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)

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education