Create a spread sheet of bank account numbers and amounts in each account for example55814 1083098123 627081164 12750Save the spread sheet as a csv file Then write a c++program that reads data fro
Here is a sample C++ program that reads data from a CSV file and displays bank accounts with more than $100 in the account:
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
using namespace std;
struct BankAccount {
string accountNumber;
double amount;
};
int main() {
string line;
ifstream file("bank_accounts.csv");
if (!file.is_open()) {
cout << "Error opening file!" << endl;
return 0;
}
BankAccount bankAccount;
while (getline(file, line)) {
stringstream ss(line);
getline(ss, bankAccount.accountNumber, ',');
ss >> bankAccount.amount;
if (bankAccount.amount > 100.0) {
cout << "Account Number: " << bankAccount.accountNumber << ", Amount: $" << bankAccount.amount << endl;
}
}
file.close();
return 0;
}
Make sure to replace "bank_accounts.csv" with the actual file name and path if necessary. Also, ensure that the CSV file is in the correct format with each line containing an account number followed by a comma and the amount
原文地址: https://www.cveoy.top/t/topic/hy6m 著作权归作者所有。请勿转载和采集!