70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
/**
|
|
* @file main.cpp
|
|
* @author Your Name
|
|
* @brief A brief description of the program.
|
|
*
|
|
* A more detailed description of the program.
|
|
*
|
|
* @version 0.1
|
|
* @date 2022-02-28
|
|
*
|
|
* @copyright Copyright (c) 2022 Your Name
|
|
*
|
|
*/
|
|
|
|
#include <iostream>
|
|
#include <fstream>
|
|
#include <iomanip>
|
|
#include <string>
|
|
|
|
using namespace std;
|
|
|
|
/**
|
|
* @brief A brief description of the main function.
|
|
*
|
|
* A more detailed description of the main function.
|
|
*
|
|
* @param argc command line argument count
|
|
* @param argv command line arguments
|
|
* @return int exit status
|
|
*/
|
|
int main(int argc, char** argv) {
|
|
// Declare variables
|
|
ifstream inFile;
|
|
ofstream outFile;
|
|
string burger_name, fries_name, icecream_name;
|
|
int burger_price, fries_price, icecream_price;
|
|
|
|
// Open the input file and output file
|
|
inFile.open("price.txt");
|
|
|
|
if (!inFile) {
|
|
cout << "Cannot open the input file."
|
|
<< "The program terminates." << endl;
|
|
return 1;
|
|
}
|
|
|
|
outFile.open("price_output.out");
|
|
cout << "Processing data" << endl;
|
|
|
|
// Read file word by word
|
|
inFile >> burger_name >> burger_price;
|
|
inFile >> fries_name >> fries_price;
|
|
inFile >> icecream_name >> icecream_price;
|
|
|
|
// Output file
|
|
outFile << "The price of " << burger_name
|
|
<< " is $" << burger_price <<"." << endl;
|
|
|
|
outFile << "The price of " << fries_name
|
|
<< " is $" << fries_price << "." << endl;
|
|
|
|
outFile << "The price of " << icecream_name
|
|
<< " is $" << icecream_price << "." << endl;
|
|
inFile.close(); //.close(): close a file
|
|
outFile.close();
|
|
cout << "Processing completed" << endl;
|
|
|
|
return 0;
|
|
}
|