Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++programming Binary File lab write a program that reads the information, conve

ID: 3810372 • Letter: C

Question

C++programming

Binary File lab

write a program that reads the information, converts all temperatures from degrees C to degrees F and all depths from centimeters to inches, then outputs the data as a new binary file, but without the fields warmestMinT and coldestMaxT. Then, read that new binary file, and write it as a text file.

the data structure for the original binary input file is as follows:

int year;

double lowestT; // temperature degrees C

double highestT; // temperature degrees C

double warmestMinT; // temperature degrees C

double coldestMaxT; // temperature degrees C

double avgMinT; // temperature degrees C

double avgMaxT; // temperature degrees C

double meanT; // temperature degrees C

double totalPrecip; // depth cm

double totalSnow; // depth cm

double max24HrPrecip; // depth cm

double max24HrSnow; // depth cm

This program should use dynamically allocated arrays of structures, functions to open for input: binary and text files, open for output: binary and text files (that would be 4 functions right there), a function to convert a single temperature value, a function to print a SINGLE structure.

The program should have your name and the date as well as the purpose.

Explanation / Answer

#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(int nNumberofArgs, char* pszArgs[])
{
//variables
string var, var1;
float cm, mile, kilometer, inch, meter, AU, fahrenheit, celsius, foot, quit, i;
//program
i = 1;
while (i <= 1000000000) {
cout << "Enter the starting unit. For a list of all units and commands, type list. To exit, type quit. Please note that this program will only loop one billion times." << endl <<endl;
cin >> var;
cout << endl;

if (var == "quit")
{
return 0;
}
//list of functions
if (var == "list")
{
cout << "For cm to inch type centimeter. For inch to cm type inch. For miles to km type mile. For km to miles type kilometer. For meters to AU or feet type meter. For AU to meters type AU. For feet to meters type feet. For fahrenheit to celsius type fahrenheit. For Celsius to Fahrenheit type celsius then rerun the program." << endl << endl << endl;
}
//inches to centimeters
if (var == "inch")
{
cout << "Please enter the number of inches" << endl;
cin >> inch;
cm = inch * 2.54;
cout << "Distance in centimeters:" << endl;
cout << cm << endl;
}
//centimeters to inches
if (var == "centimeter")
{
cout << "Please enter the number of centimeters" << endl;
cin >> cm;
inch = cm / 2.54;
cout << "Distance in inches:" << endl;
cout << inch << endl;
}
//miles to kilometers
if (var == "mile")
{
cout << "Please enter the number of miles" << endl;
cin >> mile;
kilometer = mile * 1.609344;
cout << "Distance in kilometers:" << endl;
cout << kilometer << endl;
}
//kilometers to miles
if (var == "kilometer")
{
cout << "Please enter the number of kilometers" << endl;
cin >> kilometer;
mile = kilometer / 1.609344;
cout << "Distance in miles:" << endl;
cout << mile << endl;
}
//meters to AU or feet
if (var == "meter")
{
cout << "Please select which unit you would like to convert meters to out of Astronomical units and feet" << endl;
cin >> var1;
//AU
if (var1 == "AU");
{
cout << "Please enter number of meters" << endl;
cin >> meter;
AU = meter / 149598000000;
cout << "Distance in AU:" << endl;
cout << AU << endl;
}
//feet
if (var1 == "feet")
{
cout << "Please enter number of meters" << endl;
cin >> meter;
foot = meter * 3.2808399;
cout << "Distance in feet:" << endl;
cout << foot << endl;
}
}
//AU to meters
if (var == "AU")
{
cout << "Please enter number of AU" << endl;
cin >> AU;
meter = AU * 149598000000;
cout << "Distance in meters:" << endl;
cout << meter << endl;
}
//feet to meters
if (var == "feet")
{
cout << "Please enter number of feet" << endl;
cin >> foot;
meter = foot / 3.2808399;
cout << "Distance in meters:" << endl;
cout << meter << endl;
}
//fahrenheit to celsius
if (var == "fahrenheit")
{
cout << "Please enter temperature in Fahrenheit." << endl;
cin >> fahrenheit;
celsius = (fahrenheit - 32) * (5 / 9);
cout << "Temperature in celsius:" << endl;
cout << celsius << endl;
}
//celsius to fahrenheit
if (var == "celsius")
{
cout << "Please enter temperature in Celsius." << endl;
cin >> celsius;
fahrenheit = (celsius * (9 / 5)) + 32;
cout << "Temperature in Fahrenheit:" << endl;
cout << fahrenheit << endl;
}
i++;
}
system("PAUSE");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote