Make a flowchart based on this c++ program #include #include #include #include using namespace std; //A structure that contains passenger's data struct Passenger { string flightNo; string passportNo; string name; int age; string country; double bodyTemperature; string email; }; int StoI(string num) //A function that converts a string to integer { int digit, result = 0; int i; for(i=0; i> passenger[i].flightNo; inFile >> passenger[i].passportNo; inFile >> passenger[i].name; string temp; while(inFile >> temp) { if(temp[0] >= '0' && temp[0] <= '9') { passenger[i].age = StoI(temp); break; } else { passenger[i].name += " " + temp; } } inFile >> passenger[i].country; while(inFile >> temp) { if(temp[0] >= '0' && temp[0] <= '9') { passenger[i].bodyTemperature = StoD(temp); break; } else { passenger[i].country += " " + temp; } } inFile >> passenger[i].email; i++; } int totalPassenger = i; string PassportNo; while(1) { cout << "Enter your Passport Number or enter 0 to exit: "; //Query to passenger cin >> PassportNo; if(PassportNo == "0") //Terminating condition break; j = -1; for(i=0; i 99.5) { cout << "Sorry, you need to hospitalized." << endl; } else { cout << "You can go to home quarantine." << endl; } } cout << endl; } return 0; }
Make a flowchart based on this c++ program
#include <iostream>
#include <string>
#include <math.h>
#include <fstream>
using namespace std;
//A structure that contains passenger's data
struct Passenger
{
string flightNo;
string passportNo;
string name;
int age;
string country;
double bodyTemperature;
string email;
};
int StoI(string num) //A function that converts a string to integer
{
int digit, result = 0;
int i;
for(i=0; i<num.length(); i++)
{
digit = num[i] - '0';
result = result*10 + digit;
}
return result;
}
double StoD(string num) //A function that converts a string to double
{
int digit;
double result = 0;
int i, j;
for(i=0; i<num.length(); i++)
{
if(num[i] == '.')
{
j = i;
continue;
}
digit = num[i] - '0';
result = result*10 + digit;
}
int dec = num.length()-j-1;
result /= pow(10, dec);
return result;
}
int main()
{
Passenger passenger[10]; //Creating an array of Passenger structure
int i = 0, j;
ifstream inFile; //Read from file
inFile.open("Input.txt");
string title;
getline(inFile, title); //Taking the first line of the input file
while(!inFile.eof()) //Taking Passengers' data from the input file
{
inFile >> passenger[i].flightNo;
inFile >> passenger[i].passportNo;
inFile >> passenger[i].name;
string temp;
while(inFile >> temp)
{
if(temp[0] >= '0' && temp[0] <= '9')
{
passenger[i].age = StoI(temp);
break;
}
else
{
passenger[i].name += " " + temp;
}
}
inFile >> passenger[i].country;
while(inFile >> temp)
{
if(temp[0] >= '0' && temp[0] <= '9')
{
passenger[i].bodyTemperature = StoD(temp);
break;
}
else
{
passenger[i].country += " " + temp;
}
}
inFile >> passenger[i].email;
i++;
}
int totalPassenger = i;
string PassportNo;
while(1)
{
cout << "Enter your Passport Number or enter 0 to exit: "; //Query to passenger
cin >> PassportNo;
if(PassportNo == "0") //Terminating condition
break;
j = -1;
for(i=0; i<totalPassenger; i++) //To search from the passengers' list
{
if(passenger[i].passportNo == PassportNo)
{
j = i; //Storing found index number
break;
}
}
if(i==totalPassenger) //If passenger's Passport Number is not found
cout << "Wrong Passport Number." << endl;
else
{
//Showing passenger's information
cout << "Passenger's Name : " << passenger[j].name << endl;
cout << "Passenger's Passport No. : " << passenger[j].passportNo << endl;
cout << "Passenger's Age : " << passenger[j].age << endl;
cout << "Passenger's Flight No. : " << passenger[j].flightNo << endl;
cout << "Passenger's Country : " << passenger[j].country << endl;
cout << "Passenger's Body Temperature : " << passenger[j].bodyTemperature << endl;
//Showing result
if(passenger[j].bodyTemperature > 99.5)
{
cout << "Sorry, you need to hospitalized." << endl;
}
else
{
cout << "You can go to home quarantine." << endl;
}
}
cout << endl;
}
return 0;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images