Click here to Skip to main content
15,917,862 members

Comments by hussam123 (Top 2 by date)

hussam123 15-Jan-17 10:07am View    
Deleted
I have problem how to make solve the 3 option

def main():

print('===================================================')
print('Welcome to the Train Station Accounting System :')
print('Please choose as option from the fallowings.')
value=int(input('1. Add a daily income to the database. \n2. Search daily income for a given day of a month in the database.\n3. Calculate total monthly income. \n4. Quit. \n' ))
print('===================================================')
again='y'
if value==1:
text_file=open('income.txt','a')
while again.upper()=='Y':
#get the day from the user
Day=int(input('PLEASE ENTER THE DAY OF THE MONTH :'))
#get the month name from the user
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
Income=float(input('ENTER THE DAILY INCOME TO DATABASE:'))

text_file.write('\n'+str(Day) +' '+str(Month)+' '+str(Income))
again=input('DO TOU WANT TO ADD ANOTHER INCOME? [Y/N]: ')
print('YOUR VALUES HAVE BEEN SAVED IN THE FILE !')
text_file.close()
else:
if value==2:
#get the day from the user
Day=int(input('PLEASE ENTER THE DAY OF THE MONTH :'))
#get the month name from the user
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
while Day!='' and Month!='':
found=False
text_file=open('income.txt','r')
line=text_file.readline()
while line!='':
linevalue=line.split()
if str(Day)== linevalue[0] and str(Month)==linevalue[1]:
print('The Income for the day and the month :'+linevalue[2])
found=True
line=text_file.readline()
text_file.close()
if not found:
print('THE DAY AND THE MONTH HAVE BEEN ENTERED IS NOT FOUND')

#get the day from the user
Day=int(input('PLEASE ENTER THE DAY OF THE MONTH :'))
#get the month name from the user
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
else:
if value==3:
try:
text_file=open('income.txt','r')
line=text_file.readline()
while line !='':
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
line=line.split()
for contiue in range(0,31):
if str(Month)==linevalue[contiue+1]:
total_income=total_income+float(linevalue[contiue+1])
print('THE INCOME WITHOUT INCLUDING 10% GST ='+total_income)
Income_with_GST=total_income*0.10
print('THE INCOME INCLUDING 10% GST ='+Income_with_GST)
line=text_file.readline()
text_file.close()
except FileNotFoundError:
print('text_file.txt file does not exit ......!')
except :
print('An unknown error occured ......!')



main()
hussam123 15-Jan-17 10:06am View    
Deleted
this my code I have problem to solve the 3 option



def main():

print('===================================================')
print('Welcome to the Train Station Accounting System :')
print('Please choose as option from the fallowings.')
value=int(input('1. Add a daily income to the database. \n2. Search daily income for a given day of a month in the database.\n3. Calculate total monthly income. \n4. Quit. \n' ))
print('===================================================')
again='y'
if value==1:
text_file=open('income.txt','a')
while again.upper()=='Y':
#get the day from the user
Day=int(input('PLEASE ENTER THE DAY OF THE MONTH :'))
#get the month name from the user
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
Income=float(input('ENTER THE DAILY INCOME TO DATABASE:'))

text_file.write('\n'+str(Day) +' '+str(Month)+' '+str(Income))
again=input('DO TOU WANT TO ADD ANOTHER INCOME? [Y/N]: ')
print('YOUR VALUES HAVE BEEN SAVED IN THE FILE !')
text_file.close()
else:
if value==2:
#get the day from the user
Day=int(input('PLEASE ENTER THE DAY OF THE MONTH :'))
#get the month name from the user
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
while Day!='' and Month!='':
found=False
text_file=open('income.txt','r')
line=text_file.readline()
while line!='':
linevalue=line.split()
if str(Day)== linevalue[0] and str(Month)==linevalue[1]:
print('The Income for the day and the month :'+linevalue[2])
found=True
line=text_file.readline()
text_file.close()
if not found:
print('THE DAY AND THE MONTH HAVE BEEN ENTERED IS NOT FOUND')

#get the day from the user
Day=int(input('PLEASE ENTER THE DAY OF THE MONTH :'))
#get the month name from the user
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
else:
if value==3:
try:
text_file=open('income.txt','r')
line=text_file.readline()
while line !='':
Month=str(input('PLEASE ENTER THE NAME OF THE MONTH : '))
line=line.split()
for contiue in range(0,31):
if str(Month)==linevalue[contiue+1]:
total_income=total_income+float(linevalue[contiue+1])
print('THE INCOME WITHOUT INCLUDING 10% GST ='+total_income)
Income_with_GST=total_income*0.10
print('THE INCOME INCLUDING 10% GST ='+Income_with_GST)
line=text_file.readline()
text_file.close()
except FileNotFoundError:
print('text_file.txt file does not exit ......!')
except :
print('An unknown error occured ......!')



main()