Using c++ 03 language standard programming. Using simple technique such as (If &
ID: 3910964 • Letter: U
Question
Using c++ 03 language standard programming. Using simple technique such as (If &else), WEATHER BALLOON CHARACTERISTICS You will develop a program for simulating the characteristics of three weather balloons. Your instructor will assign which three balloons from the total inventory of six weather balloons that you will model in your program. Users would like to learn about the behaviors of the assigned weather balloons. Your program will provide output data in a file for each selected weather balloon's performance. The user will select the weather balloon, and your program will provide a table in the output data file with time, height and velocity. There are six different weather balloons in the inventory: WB 1, WB 2, WB_3, WB 4, WB 5, and WB 6. Each has different flight characteristics (height and velocity behavior, as in the table below). Height and velocity equations and related parameter values for each balloon are provided below. Height Equation (function of time) A1+B1xt+ci + Dixt+ E1 Velocity Equation (function of time) A2t+B2x+c2xt+ D2xt+ E2 EQUATION PARAMETER VALUES FOR THE BALLOONS A1 81 C1 D1E1 A2 B2 C2 D2 E2 WB 10.1212380 4100 220 0 0.48 36760 4100 WB 21-0, 111 10 | -235| 3850| 178 | 0 .0.5 | 34 | .564 |3450 WB 3-0.18 14401 4860 235 00.639 -8434300 WB 4 -0.19 15 325 5030 226 -0.6437 6053950 WB S 017 15 370 5410 08 0 0S1 40 -746 4240 WB 6 -0.15 16 -381 5790 241 10 -0.464 -888 4025 Page 1 USER INPUTS Two inputs a) Selection of the weather balloon b) Time frame of the light simulator BALLOON: User will be able to select the weather balloon to learn about the Height and Velocity within the requested time frame. The menu options (presented by the myMenu function) are: 1. Option 1 Weather balloon 3 (WB3 2. Option 2 Weather balloon 4 (WB 4) 3. Option 3 Weather balloon 5 (WB 5) 4. Exit TIME: User will be able to select the time/duration to record/observe the behaviors of the balloon. Enter initial value of time (in hours) Enter the time increment (in hours) Enter the final value of time (in hours) FUNCTIONS (required) You are expected to develop three functions for this project: 1. myMenu shows the main menu with four options myAititude calculates the height (in meters) by using the provided height equation formula 2.Explanation / Answer
ScreenShot
----------------------------------------------------------------
Program
//Header files for I/O,output formatting and file operation
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
//Function prototypes
void myMenu();
double myAltitude(double A1, double B1, double C1, double D1, double E1,int t);
double myVelocity(double A2, double B2, double C2, double D2, double E2, int t);
int main()
{
//File write object creation
ofstream out3;
ofstream out4;
ofstream out5;
//Variable declaration for looping choice and function value pass
int ch1 = 0, totalHours=0;
double ti=0,ts=0,tf=0,A1=0,B1=0,C1=0,D1=0,E1=0,A2=0,B2=0,C2=0,D2=0,E2=0,i=0;
//Loop to check the user enter 4(exit)
do {
//Display menu
myMenu();
//Prompt user to enter choice
cout << "Please enter your choice(1-4):";
cin >> ch1;
//Loop through until get correct response
while (ch1 < 0 || ch1>4) {
cout << "You have to enter number from1 to 4!!!" << endl;
myMenu();
cout << "Please enter your choice(1-4):";
cin >> ch1;
}
//According tothe choice perform different operation
switch (ch1) {
//Calculate height and velocity according to time and write into a file
case 1:
//Time interval prompt
cout << "Enter initial value of time (in hours): ";
cin >> ti;
cout << "Enter the time increment (in hours): ";
cin >> ts;
cout << "Enter the final value of time (in hours): ";
cin >> tf;
totalHours = tf - ti;
//Loop through unti get correct input
while (totalHours < 5 || totalHours>24) {
cout << "Total time always greater than 5 and less than 24!!!" << endl;
cout << "Enter initial value of time (in hours): ";
cin >> ti;
cout << "Enter the time increment (in hours): ";
cin >> ts;
cout << "Enter the final value of time (in hours): ";
cin >> tf;
totalHours = tf - ti;
}
//Assign values to variables to pass as an argument to functions
A1 = -0.18, B1 = 14, C1 = -401, D1 = 4860, E1 = 235, A2 = 0, B2 = -0.6, C2 = 39, D2 = -843, E2 = 4300;
//Open file and write
out3.open("C:/Users/deept/Desktop/Lastname_WB_3.txt", std::ios_base::app);
if (!out3) {
cout << "File not found" << endl;
exit(0);
}
else {
for (i = ti; i <= tf; i = i + ts) {
cout << fixed << setprecision(2);
out3 << i << " " << myAltitude(A1, B1, C1, D1, E1, i) << " " << myVelocity(A2, B2, C2, D2, E2, i) << endl;
}
}
out3 << endl;
//File write completed information
cout << "File write completed!!" << endl;
out3.close();
break;
//Do balloon 4 details
case 2:
cout << "Enter initial value of time (in hours): ";
cin >> ti;
cout << "Enter the time increment (in hours): ";
cin >> ts;
cout << "Enter the final value of time (in hours): ";
cin >> tf;
totalHours = tf - ti;
while (totalHours < 5 || totalHours>24) {
cout << "Total time always greater than 5 and less than 24!!!" << endl;
cout << "Enter initial value of time (in hours): ";
cin >> ti;
cout << "Enter the time increment (in hours): ";
cin >> ts;
cout << "Enter the final value of time (in hours): ";
cin >> tf;
totalHours = tf - ti;
}
A1 = -0.19, B1 = 15, C1 = -325, D1 = 5030, E1 = 226, A2 = 0, B2 = -0.64, C2 = 37, D2 = -605, E2 = 3950;
out4.open("C:/Users/deept/Desktop/Lastname_WB_4.txt", std::ios_base::app);
if (!out4) {
cout << "File not found" << endl;
exit(0);
}
else {
for (i = ti; i <= tf; i = i + ts) {
cout << fixed << setprecision(2);
out4 << i << " " << myAltitude(A1, B1, C1, D1, E1, i) << " " << myVelocity(A2, B2, C2, D2, E2, i) << endl;
}
}
out4 << endl;
cout << "File write completed!!" << endl;
out4.close();
break;
//do Ballon 5 details
case 3:
cout << "Enter initial value of time (in hours): ";
cin >> ti;
cout << "Enter the time increment (in hours): ";
cin >> ts;
cout << "Enter the final value of time (in hours): ";
cin >> tf;
totalHours = tf - ti;
while (totalHours < 5 || totalHours>24) {
cout << "Total time always greater than 5 and less than 24!!!" << endl;
cout << "Enter initial value of time (in hours): ";
cin >> ti;
cout << "Enter the time increment (in hours): ";
cin >> ts;
cout << "Enter the final value of time (in hours): ";
cin >> tf;
totalHours = tf - ti;
}
A1 = -0.17, B1 = 15, C1 = -370, D1 = 5410, E1 = 208, A2 = 0, B2 = -0.51, C2 = 40, D2 = -746, E2 = 4240;
out5.open("C:/Users/deept/Desktop/Lastname_WB_5.txt", std::ios_base::app);
if (!out5) {
cout << "File not found" << endl;
exit(0);
}
else {
for (i = ti; i < tf; i = i + ts) {
cout << fixed << setprecision(2);
out5 << i << " " << myAltitude(A1, B1, C1, D1, E1, i) << " " << myVelocity(A2, B2, C2, D2, E2, i) << endl;
}
}
out5 << endl;
cout << "File write completed!!" << endl;
out5.close();
break;
//Exit from the program
case 4:
exit(0);
break;
}
} while (ch1 != 4);
return 0;
}
//myMenu function definition
void myMenu() {
cout << "1. Option 1 Weather balloon 3(WB_3) 2. Option 2 Weather balloon 4(WB_4) 3. Option 3 Weather balloon 5(WB_5) 4. Option 1 Exit ";
}
//Find height at particular time
double myAltitude(double A1, double B1, double C1, double D1, double E1,int t) {
return ((A1*pow(t, 4)) + (B1*pow(t, 3)) + (C1*pow(t, 2)) + (D1*t) + E1);
}
//Find velocity at particular time
double myVelocity(double A2, double B2, double C2, double D2, double E2, int t) {
return ((A2*pow(t, 4)) + (B2*pow(t, 3)) + (C2*pow(t, 2)) + (D2*t) + E2);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.