Created
June 6, 2021 23:24
-
-
Save Ellsworth/4f591c195913350849807a1b1c8fb06c to your computer and use it in GitHub Desktop.
CS1428 Project 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ship name: Starfinder | |
Designer name: Albert Einstein | |
Ship mass: 500 | |
Engine thrust: 1000 | |
File written for Starfinder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##########Starfinder########## | |
Designed By: Albert Einstein | |
Ship mass: 500kg | |
Accleration: 2.0m/s2 | |
Delta V: 679.3m/s | |
Max Altitude: 147.9km | |
File saved at: 1623021677 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Name: Erich Ellsworth | |
// netID: wqi7 | |
#include <iostream> | |
#include <iomanip> | |
#include <string> | |
#include <math.h> | |
#include <fstream> | |
using namespace std; | |
int main() | |
{ | |
// variables setup. | |
string shipName, designerName; | |
float shipMass, engineThrust, shipAcceleration, shipDeltaV, maxAltitude; | |
cout << "Ship name: "; | |
cin >> shipName; | |
// We need to flush out the newline character, or else getLine will read it. | |
cin.ignore(); | |
cout << "Designer name: "; | |
getline(cin, designerName); | |
cout << "Ship mass: "; | |
cin >> shipMass; | |
cout << "Engine thrust: "; | |
cin >> engineThrust; | |
ofstream out_file; | |
out_file.open(shipName + ".txt"); | |
// Calcuate values from values given by user. | |
shipAcceleration = engineThrust / shipMass; | |
shipDeltaV = (100000 / engineThrust) * 9.8 * log(2); | |
maxAltitude = 100 + (shipDeltaV - 200) / 10; | |
cout << "File written for " << shipName; | |
out_file << "##########" << shipName << "##########" << endl; | |
out_file << "Designed By: \t\t" << designerName << endl; | |
out_file << "Ship mass: \t\t" << shipMass << "kg" << endl; | |
out_file << "Accleration: \t\t" << setprecision(1) << fixed << shipAcceleration << "m/s2" << endl; | |
out_file << "Delta V: \t\t" << setprecision(1) << fixed << shipDeltaV << "m/s" << endl; | |
out_file << "Max Altitude: \t\t" << setprecision(1) << fixed << maxAltitude << "km" << endl; | |
out_file << endl << "File saved at:\t\t" << time(NULL); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment