15,917,862 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
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()