Answer:
See explaination
Step-by-step explanation:
#include<iostream>
#include<vector>
#include<string>
#include<iostream>
#include<fstream>
using namespace std;
class BibleBooks{
public:
BibleBooks(string bk_title, int chapters, double percentage){
title=bk_title;
numChapters=chapters;
amountRead=percentage;
}
string getTitle(){
return title;
}
int getChapters(){
return numChapters;
}
double getPercentage(){
return amountRead;
}
private:
string title;
int numChapters;
double amountRead;
};
int main(){
char filename[200];
cout<<"Enter filename: ";
cin.get(filename,199);
vector<BibleBooks> bibleBooks;
ifstream infile(filename);
if(infile.is_open()){
string title; int chapters; double percentage;
while(infile>>title>>chapters>>percentage){
BibleBooks bb = BibleBooks(title,chapters,percentage);
bibleBooks.push_back(bb);
}
infile.close();
}else{
cout<<"Unable to read data from file: "<<filename;
}
//Your program will then iterate through the vector,
// displaying all of the information about each object.
int index_lowest_read=0;
for(int i=0; i<bibleBooks.size();i++){
cout<<bibleBooks.at(i).getTitle()<<" "
<<bibleBooks.at(i).getChapters()<<" "
<<bibleBooks.at(i).getPercentage()<<endl;
if(bibleBooks.at(index_lowest_read).getPercentage()>
bibleBooks.at(index_lowest_read).getPercentage()){
index_lowest_read=i;
}
}
cout<<"The book with the lowest amount read is "
<<bibleBooks.at(index_lowest_read).getTitle()<<endl;
}