write a program that generate a report( bill) of utility using the folloing text
ID: 3782384 • Letter: W
Question
write a program that generate a report( bill) of utility using the folloing text file as an input.(the text file has: AcctNum, name, previous , current). your out put should display the following information: under the title Account # - list of AcctNums, under the title Name -list of names , under the title Previous- list of previous; under the title Current - list of currets; under the title Charge - list of chages. Here is the calculation of charge: (prvious - current) *1,525. and ,at the last the total billed.
the text file:
111111 Fred Flintstone 123.4 234.5
222222 Barney Rubble 234.5 333.3
333333 Homer Simpson 345.6 1345.6
444444 Wile E Coyote 0.0 1.0
Explanation / Answer
AcctNum, name, previous , current
*******(as you didn't mentioned in which language scriptto be written, i preferred python and if your file is csv(comma seperated file))*********
import sys,os,csv
x = raw_input("Enter name of file to be written row wise:")
ui = "x" + txt
for ui in x:
data = open("ui").readlines()
outfile = open("myfile.csv","w")
out = csv.writer(outfile)
list1=[]
for row in data:
row = row.strip().split(';')
if row:
for subrow in row:
subrow = subrow.strip().split()
if subrow:
list1.appen(subrow)
l1=[]
l2=[]
l3=[]
l4=[]
j=0
for i in range(len(list1)/4):
l1.append(list1[j])
l2.append(list1[j+1])
l3.append(list1[j+2])
l4.append(list1[j+3])
j=i+4
for i in l1:
print("Account")
print(i)
for i in l2:
print("Name")
print(i)
for i in l3:
print("Previous")
print(i)
for i in l4:
print("Current")
print(i)
for i in range(len(l3):
charge=(l3[i]-l4[i])*1525
print("Charge")
print(charge)
outfile.close()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.