Question

In: Computer Science

Establishing a method for collecting rent each month will make it easier to keep track of...

Establishing a method for collecting rent each month will make it easier to keep track of the rent collection process. Choose the number of houses and rent per house by your choice. Develop a python program to maintain the rent collection process. Update the database with the details of every month like the name of the tenant, house number, month of the rent, rent amount, EB bill amount, maintenance charge, etc., Print the details of rent collection for all houses from January 2019 to December 2019. Also, print the details of the month in which the tenant has joined/vacated house wise.

Solutions

Expert Solution

Program with explanation:

import mysql.connector

#following lines create a connection to the database

mydb = mysql.connector.connect(
host="localhost",
user="myusername",
password="mypassword",
database="mydatabase"
)

mycursor = mydb.cursor()

#create RentCollection table with all required fields

mycursor.execute("CREATE TABLE RentCollection (TenentName VARCHAR(255),HouseNumber int,MonthofRent VARCHAR(255),RentAmount int,EBbillAmount int,MaintCharge int,monJoined DATE)") #SQL command

#Get the number of houses as user input

no_of_houses = input("Enter number of houses: ")

#insert inital values to each house using INSERT command in sql
for x in range(no_of_houses):
sql = "INSERT INTO RentCollection (TenentName ,HouseNumber,MonthofRent ,RentAmount,EBbillAmount,MaintCharge) VALUES (%s, %s,%s, %s,%s, %s, %s)" #SQL command
val = tuple(map(int, input("Enter TenentName ,HouseNumber,MonthofRent ,RentAmount,EBbillAmount,MaintCharge,monJoined: ").split()))
mycursor.execute(sql, val)
mydb.commit()   #save the changes

#update required values to each house using UPDATE command in sql

for x in range(no_of_houses):
sql = "UPDATE customers SET TenentName=%S ,HouseNumber=%S,MonthofRent=%S ,RentAmount=%S,EBbillAmount=%S,MaintenanceCharge=%S WHERE HouseNumber=%S" #SQL command
val = tuple(map(int, input("Enter TenentName ,HouseNumber,MonthofRent ,RentAmount,EBbillAmount,MaintCharge, old houseno: ").split()))
mycursor.execute(sql, val)
mydb.commit() #save the changes

#print all rental information from table using SELECT command

mycursor.execute("SELECT TenentName ,HouseNumber,MonthofRent ,RentAmount,EBbillAmount,MaintCharge FROM RentCollection")   #SQL command
myresult = mycursor.fetchall()
for x in myresult:
print(x)

#print tenent information from table using SELECT command

mycursor.execute("SELECT TenentName ,HouseNumber,monJoined FROM RentCollection")    #SQL command
myresult = mycursor.fetchall()
for x in myresult:
print(x)


Related Solutions

In this assignment, the program will keep track of the amount of rainfall for a 12-month...
In this assignment, the program will keep track of the amount of rainfall for a 12-month period. The data must be stored in an array of 12 doubles, each element of the array corresponds to one of the months. The program should make use of a second array of 12 strings, which will have the names of the months. These two arrays will be working in parallel. The array holding the month names will be initialized when the array is...
You will be building a linked list. Make sure to keep track of both the head...
You will be building a linked list. Make sure to keep track of both the head and tail nodes. (1) Create three files to submit. PlaylistNode.h - Class declaration PlaylistNode.cpp - Class definition main.cpp - main() function Build the PlaylistNode class per the following specifications. Note: Some functions can initially be function stubs (empty functions), to be completed in later steps. Default constructor (1 pt) Parameterized constructor (1 pt) Public member functions InsertAfter() - Mutator (1 pt) SetNext() - Mutator...
For ONE day, keep track of all of the electrical devices that you make use of...
For ONE day, keep track of all of the electrical devices that you make use of and for how long. (eg. Microwave oven for 3 minutes; hair dryer for 5 minutes; TV for 90 minutes;...) Track only those devices over which you have direct control and don’t bother about things like home heating and refrigerators that are too challenging to track. Using either a published table of common power ratings (cite your source), or information read off of the device...
As you complete each of the following steps, keep track of what occurs at each point;...
As you complete each of the following steps, keep track of what occurs at each point; including what you type, the output given, and any errors experienced. Submit this information in a log to your instructor for this week’s assignment. Your log can use the sample format provided, or you can create your own. 1. Run the following script: a. #!/bin/bash b. count=1 c. echo "start of the program" d. while [ $count -le 10 ] e. do 1) echo...
Use C++ please You will be building a linked list. Make sure to keep track of...
Use C++ please You will be building a linked list. Make sure to keep track of both the head and tail nodes. (1) Create three files to submit. PlaylistNode.h - Class declaration PlaylistNode.cpp - Class definition main.cpp - main() function Build the PlaylistNode class per the following specifications. Note: Some functions can initially be function stubs (empty functions), to be completed in later steps. Default constructor (1 pt) Parameterized constructor (1 pt) Public member functions InsertAfter() - Mutator (1 pt)...
/////////////////JAVA PLEASE///////////////////////////////// Create a class called GVdate to keep track of a calendar date including month,...
/////////////////JAVA PLEASE///////////////////////////////// Create a class called GVdate to keep track of a calendar date including month, day and year.  You can do simple things like checking if it is your birthday, advancing to the next day, checking if a given date is valid and checking if it is a leap year. Class Fields/Instance Variables Provide appropriate names and data types for each of the private instance variables: the month, day and year (int) two final integers that represent YOUR birthday (month...
C program: 1, Make two parallel arrays, one to keep track of food names and another...
C program: 1, Make two parallel arrays, one to keep track of food names and another to keep track of the food prices. There will be a total of 10 items, with a total of about 100 characters for each food name title (i think we can use malloc for the strings and allocate it accordingly) Basically it will be something like a menu: 1, we will enter the food information 2, it will list all the food names and...
The owner of a small restaurant that sells burgers pays each month $1,000 in rent, $300...
The owner of a small restaurant that sells burgers pays each month $1,000 in rent, $300 in utilities, $200 interest on his loan, and $500 on advertising on local buses. A burger sandwich is priced at $4.00. Unit variable costs for the burger sandwich is $2.00. Calculate unit margin and monthly fixed cost. How many sandwiches does the restaurant need to sell to break-even each month? Calculate Total Cost at Break even Calculate Total Revenue at Break even. How many...
Insert at least three rows of data to each table. Make sure you keep the primary...
Insert at least three rows of data to each table. Make sure you keep the primary key and foreign key constraints. Tables: Cust Table: cid, -- customer id cname, --- customer name cphone, --- customer phone cemail, --- customer email Category table: ctid, --- category id ctname, --- category name parent, --- parent category id since category has a hierarchy structure, power washers, electric power washers, gas power washers. You can assume that there are only two levels. Tool: tid,...
Part1) Bob's Apartment Building has 100 units that rent for $1,110 per month each. What is...
Part1) Bob's Apartment Building has 100 units that rent for $1,110 per month each. What is the Gross Potential Income for Bob's Apartment Building? Part2) Bob's Apartment Building has gross potential income of $1,000,000. The expected vacancy rate is 13%. Collection losses are 5% (after allowing for vacancies). Incidental income is $50,000 per year. What is the Effective Gross Income for Bob's Apartment Building? Part3) Bob's Apartment Building has effective gross income of $500,000. Operating expenses are 38% of revenue....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT