program6_1.py BetterBuy is having a sale. Write a program that uses a while loop to store to a file the names, regular prices, and price reductions (as percents) for selected items in the promotion. The program should enable the user to enter this data from the keyboard as shown below . Each datum should be stored on its own line in the file. i already finished this program and came up with this code: f = open('data.txt', 'w+') while(True):     name = input("Enter item name or Enter to quit ")     if name == "" :         break     cost = input("Enter item's regular price ")     reduction = input("Enter reduction percent for sale ")     f.write(name + ' ' + cost + ' ' + reduction + ' \n') f.close() print("File was created")   i need program6_2.py

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

program6_1.py
BetterBuy is having a sale. Write a program that uses a while loop to store to a file the namesregular prices, and price reductions (as percents) for selected items in the promotion. The program should enable the user to enter this data from the keyboard as shown below . Each datum should be stored on its own line in the file.

i already finished this program and came up with this code:

f = open('data.txt', 'w+')
while(True):
    name = input("Enter item name or Enter to quit ")
    if name == "" :
        break
    cost = input("Enter item's regular price ")
    reduction = input("Enter reduction percent for sale ")
    f.write(name + ' ' + cost + ' ' + reduction + ' \n')
f.close()
print("File was created")

 

i need program6_2.py

 

ITEM
REG. PRICE
REDUCED
SALE PRICE
laptop
899.99
225.00
674.99
router
229.95
91.98
137.97
printer
monitor
399.99
80.00
319.99
425.79
127.74
298.05
Transcribed Image Text:ITEM REG. PRICE REDUCED SALE PRICE laptop 899.99 225.00 674.99 router 229.95 91.98 137.97 printer monitor 399.99 80.00 319.99 425.79 127.74 298.05
Expert Solution
Python Program

f = open('data.txt', 'w+')
#f.write('ITEM\tREG.PRICE\tREDUCED\t\tSALE PRICE\n')
f.write(f"{'ITEM' : <10}{'REG.PRICE' : >10}{'REDUCED' : >10}{'SALE PRICE' : >18}\n")
while(True):
    name = input("Enter item name or Enter to quit ")
    if name == "" :
        break
    cost = input("Enter item's regular price ")
    reduction = input("Enter reduction percent for sale ")
    newCost = str(float(cost) - float(reduction))
    
    f.write(f"{name : <10}{cost : >10}{reduction : >10}{newCost : >18}\n")
    #f.write(name + "\t" + cost + "\t\t" + reduction + "\t\t" + newCost + "\n")
    
f.close()
print("File was created")

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Stack operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education