Each line in the file will consist of four items: 1. Customer last name (string,
ID: 3617000 • Letter: E
Question
Each line in the file will consist of four items:
1. Customer last name (string, up to 15characters, no spaces)
2. Storage space number (whole number in therange 1 to 99999)
3. Monthly rental price (decimal value up to999.99)
4. Storage space size (one character: S, M,L, or X)
(Items will beseparated by whitespace; all data will be valid)
Your program should prompt the user to input a storage spacenumber. If the number exists, it should display all dataabout that storage space with appropriate labels. If thestorage space number does not exist, it should display a message onthe screen saying so. This process should be repeated overand over again until the user enters 0 for the storage spacenumber.
You must use a struct within an array to store the data. You may assume that there will be no more than 100 storage spaces,but your program should work for any number of spaces up through100. You must use the binary search routine (see page 570) tolocate a storage space number. Use appropriate functions forseparate tasks. Do not access global variables except for thefiles. Follow the documentation guidelinesprovided.
Explanation / Answer
please rate - thanks #include #include #include using namespace std; #define MAX 100 struct rental { char last[15]; int space; double rent; char size; } unit[MAX]; void getinfo(rental[],ifstream &,int&); void search(rental[],int,int); int main() {int num; ifstream in; char filename[15]; int count=0; coutfilename; in.open(filename); if(in.fail()) //is it ok? { coutunit[count].space>>unit[count].rent>>unit[count].size; count++; in>>unit[count].last; } return; } void search(rental unit[],int max,int key) {int i,j,low=0,mid; max--; while(lowRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.