Question

write a c++ program :Assume one of the companies is renting flats for people asks you...

write a c++ program :Assume one of the companies is renting flats for people asks you to develop a small system to help them track who paid the rent fees, and who did not for the coming month. The data in this system includes: ID number of the person who rented the house, flat number , fine to be paid, tenant name, status of payment(paid or unpaid ).

The main interface of the system should be as follows:

1- Add a new rent record (Renter ID, Renter name, Flat Number, Fine, and status).

2- Display all renters’ information.

3- Search for rent information by Flat number.

4- Display all rent information that are not paid yet.

5- Exit.

When user selects 1, the system asks user to enter data of the rent record which includes: renter id, renter name, flat number, fine, and status. The data will be saved in a file.  When user selects 2: the system displays data of all rent information saved in the file.  When users selects 3, the system asks for the flat number, if there is no information saved on such flat, then a message is displayed “here is no information saved on such flat number”, otherwise, system displays all data about the rent information of that flat.  When user selects 4, the system displays data of rent records that are unpaid yet.  When user selects 5, exit the system, otherwise system returns to the main menu.

Hint: use fstream header to use the files to store the data.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

rent.cpp:

#include<iostream>
#include<string.h>
#include<fstream>
using namespace std;
int j=0;
struct rentRecords { //structure to store the data of rent
   int renterID;
   char renterName[20];
   int flatNumber;
   int fine;
   char status[10];
   }records[5];
  
   void addnewRecord() { //method to add rent details
   cout<<"Enter renter ID: ";
   cin>>records[j].renterID;
   cout<<"Enter renter Name: ";
   cin>>records[j].renterName;
   cout<<"Enter flat Number: ";
   cin>>records[j].flatNumber;
   cout<<"Enter fine: ";
   cin>>records[j].fine;
   cout<<"Enter the rent status: ";
   cin>>records[j].status;
   j++;
   }
  
   void displayAll() { //method to display all renters information
   for(int k=0; k<j; k++) {
   cout<<"Renter ID: "<<records[k].renterID<<"\n";
   cout<<"Renter Name: "<<records[k].renterName<<"\n";
   cout<<"Flat Number: "<<records[k].flatNumber<<"\n";
   cout<<"Fine: "<<records[k].fine<<"\n";
   cout<<"Rent status: "<<records[k].status<<"\n";
   }
   }
   void getInformation(int n) { //method to display the details of particular flat number
   int flag =0;
   for(int a =0; a<j; a++) {
   if(records[a].flatNumber == n) {
   cout<<"Renter ID: "<<records[a].renterID<<"\n";
   cout<<"Renter Name: "<<records[a].renterName<<"\n";
   cout<<"Flat Number: "<<records[a].flatNumber<<"\n";
   cout<<"Fine: "<<records[a].fine<<"\n";
   cout<<"Rent status: "<<records[a].status<<"\n";
   } else {
   flag = 1;
   }
   }
   if(flag==1) {
   cout<<"here is no information saved on such flat number."<<endl;
   }
   }
     
     
   void notPaidResults() { //method to get details of unpaid tenants
   for(int k=0; k<j; k++) {
   if(strcmp(records[k].status, "unpaid")==0) {
   cout<<"Renter ID: "<<records[k].renterID<<"\n";
   cout<<"Renter Name: "<<records[k].renterName<<"\n";
   cout<<"Flat Number: "<<records[k].flatNumber<<"\n";
   cout<<"Fine: "<<records[k].fine<<"\n";
   cout<<"Rent status: "<<records[k].status<<"\n";
   }
   }
   }
     
   int main() {
   char ch;
   while(ch!='q') {
   cout<<"1.Add new Rent Record."<<endl;
   cout<<"2.Display all renters information."<<endl;
   cout<<"3.search for rent inormation by flat number."<<endl;
   cout<<"4.Display all rent information that are not paid yet."<<endl;
   cout<<"5.Exit."<<endl;
   cout<<"Enter your choice: ";
   cin>>ch;
   fflush(stdin);
   switch(ch) {
   case '1': addnewRecord();
               break;
   case '2': displayAll();
               break;
   case '3': cout<<"Enter the flat number: ";
           int num;
           cin>>num;
           getInformation(num);
           break;
   case '4': notPaidResults();
           break;
   case '5': exit(0);
           break;
   default: cout<<"Wrong Choice! Try again."<<"\n";
               break;
   }
   }
   }

Output:

Add a comment
Know the answer?
Add Answer to:
write a c++ program :Assume one of the companies is renting flats for people asks you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Phase one implementation: 1-The menu of selections implemented in main function. 2- Each choice should be...

    Phase one implementation: 1-The menu of selections implemented in main function. 2- Each choice should be implemented in the main function. 3- The data is saved permanently in a file. Problem Description: Assume one of the companies in Qatar who is renting flats for people asks you to develop a small system to help them track who paid the rent fees, and who did not for the coming month. The data in this system includes: ID number of the person...

  • C++ program Write a C++ program to manage a hospital system, the system mainly uses file...

    C++ program Write a C++ program to manage a hospital system, the system mainly uses file handling to perform basic operations like how to add, edit, search, and delete record. Write the following functions: 1. hospital_menu: This function will display the following menu and prompt the user to enter her/his option. The system will keep showing the menu repeatedly until the user selects option 'e' from the menu. Arkansas Children Hospital a. Add new patient record b. Search record c....

  • Please solve using c++ plus There are two text files with the following information stored in...

    Please solve using c++ plus There are two text files with the following information stored in them: The instructor.txt file where each line stores the id, name and affiliated department of an instructor separated by a comma The department.txt file where each line stores the name, location and budget of the department separated by a comma You need to write a C++ program that reads these text files and provides user with the following menu: 1. Enter the instructor ID...

  • Write a contacts database program that presents the user with a menu that allows the user...

    Write a contacts database program that presents the user with a menu that allows the user to select between the following options: (In Java) Save a contact. Search for a contact. Print all contacts out to the screen. Quit If the user selects the first option, the user is prompted to enter a person's name and phone number which will get saved at the end of a file named contacts.txt. If the user selects the second option, the program prompts...

  • C++ program.The program contains 4 options for user to choose.First is addStudent,which when selected asks for...

    C++ program.The program contains 4 options for user to choose.First is addStudent,which when selected asks for contact information,the second option addTeacher asks for same contact information(we have to use inheritance here) and asks for years of Experience.The third and fourth options are display Student and display Teacher respectively which displays all the data entered.The student and teacher are different classes where teacher extends student.Both student and teacher information should be stored in arrays and so display options just prints out...

  • PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program...

    PROGRAMMING LANGUAGE OOP'S WITH C++ Functional Requirements: A jewelry designer friend of mine requires a program to hold information about the gemstones he has in his safe. Offer the jewelry designer the following menu that loops until he chooses option 4. 1. Input a gemstone 2. Search for a gemstone by ID number 3. Display all gemstone information with total value 4. Exit ------------------------------------- Gemstone data: ID number (int > 0, must be unique) Gem Name (string, length < 15)...

  • C Programming Write a C program that asks the user for a positive number n (n...

    C Programming Write a C program that asks the user for a positive number n (n ≥ 1) then, the program displays all the perfect numbers up to (including) n. A number n is said to be a perfect number if the sum of all its positive divisors (excluding itself) equals n. For example, the divisors of 6 (excluding 6 itself) are 1,2 and 3, and their sum equals 6, thus, 6 is a perfect number. Display the numbers with...

  • Looking for some help with this Java program I am totally lost on how to go about this. You have been approached by a local grocery store to write a program that will track the progress of their sale...

    Looking for some help with this Java program I am totally lost on how to go about this. You have been approached by a local grocery store to write a program that will track the progress of their sales people (SalesPerson.java) The information needed are: D Number integer Month 1 Sales Amount-Double Month 2 Sales Amount-Double Month 3 Sales Amount-Double Write a Java program that allows you to store the information of any salesperson up to 20 While the user...

  • In C program Consider a file that contains employee records, called "empstat.txt." The data for each...

    In C program Consider a file that contains employee records, called "empstat.txt." The data for each employee consist of the employee’s last name (up to 20 characters), employee id number (up to 11 characters), gross pay for the week (double), taxes deducted (double) for the week, and net pay (double) for the week. Create a struct to hold the employee information. Write a void function called writeEmpFile that prompts the user to enter last name, id number, gross pay and...

  • You are to write a program IN C++ that asks the user to enter an item's...

    You are to write a program IN C++ that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: if the an item's wholesale cost is 5.00 and its markup percentage is 100%, then the item's retail price is 10.00 If an item's wholesale cost is 5.00 and its markup percentage is 50%, then the item's retail price is 7.50 Program design specs. You should have 5...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT