1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Eddi Din [679]
4 years ago
5

A manager keeps a record of daily each transaction in input.txt. Each line contains three items: The invoice number, the cash am

ount, and the letter P refers to the amount that has been paid or R if it was received. Items are separated by spaces. Write a program that prompts the manager to provide the opening cash balance, the closing cash balance, and the file name (i.e., input.txt) that the manager wants to read. Then, your program should check whether the closing cash balance equals the expected value after processing input.txt.

Computers and Technology
1 answer:
Scilla [17]4 years ago
3 0

Answer:

See explaination for code

Explanation:

# Take user input

opening_balance = float(input('Enter the opening cash balance: '))

closing_balance = float(input('Enter the closing cash balance: '))

filename = input('Enter the file name: ')

# Open file to read

fileread = open(filename, 'r')

# Set file_balance to opening balance

file_balance = opening_balance

# Iterate over file

# Split line to get data from it

for line in fileread.readlines():

data = line.rstrip().split()

# Add payment is R means Received else subtract

if data[2] == "R":

file_balance += float(data[1])

else:

file_balance -= float(data[1])

# Check if equal and print message accordingly

if file_balance == closing_balance:

print('The closing balance is correct')

else:

print('The closing balance didn\'t match.\nAccording to the file, it should be', file_balance)

Please kindly check attachment for screenshot and output.

You might be interested in
Which option is the easiest way to configure macros in Access 2016?
zhuklara [117]
Number 2
Have a nice day
6 0
3 years ago
Why might you receive a tax refund from the irs
Harrizon [31]
Im not quite sure but i got mine back yesterday soooo (pretty good)

8 0
4 years ago
There is one clear definition of IT. True False
Elenna [48]

Answer:

That is False. it has more definitions not only one.

8 0
3 years ago
Postsecondary certificated programs are commonly referred to as:
denpristay [2]
I believe it is commonly referred as a college/vocational school/ or a university.
3 0
3 years ago
True or False: Cracking a Vigenère cipher with brute force takes longer than a Caesar cipher, but it is still a reliable method
iragen [17]

Answer:

False

Explanation:

The Vigenere cipher is an encryption method that uses a series of interwoven Ceaser ciphers and a keyword to encrypt text. The difference between this cipher and the Ceaser cipher is the tabular interwoven Ceaser cipher and the keyword.

Multiple keywords can be used in the Vigenere cipher. The use of this keyword makes the brute-force decipher algorithm unreliable for decoding text encrypted with it.

7 0
3 years ago
Other questions:
  • The shortcut key to access the spelling and grammar check is _____.
    11·2 answers
  • Why do you need to back up important data?
    5·2 answers
  • The Cursor is blinking in a white area on the Screen. This area where text will appear in the ____.
    10·2 answers
  • A ____ is used to perform a forward-only (sequential) access of the data in the data source while a ____ is used to populate a d
    11·1 answer
  • Can Anybody Answer This
    8·1 answer
  • A mobile device you are troubleshooting is experiencing a sharp decrease in performance after an hour of operation. The user pow
    12·1 answer
  • Someone help please!! i’ll give brainliest
    11·2 answers
  • B) Describe the computer processing that is required to maintain the correct growing<br>conditions.​
    13·1 answer
  • Define operator precedence ? explain with an example.​
    13·1 answer
  • Select the three subjects studied in sports biomechanics.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!