Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8913437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:27:52+00:00 2026-06-15T04:27:52+00:00

Simulate a cash register as it totals a user’s purchases. The program should execute

  • 0

Simulate a cash register as it totals a user’s purchases. The program should execute for an unspecified number of items for a single user. The program should prompt the user for the quantity and unit cost of each item. The user should indicate the end of purchases by entering a negative quantity. The program should output on one line the quantity, unit cost, item total (the quantity times the unit cost), and the current subtotal to the file purchases.txt. These values should be separated by a space. The program should output the final total to both the file and the screen.

I have the file I/O down pretty well. What I’m having trouble in class with is creating my loops and making them stop when something is entered.

import os.path
outFile = open("purchases","w")
quantity = raw_input("What is the quantity of the item")
cost = raw_input("How much is each item")
outFile.write()
while quantity <= ???? : 

I understand the math but the loop just loses me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:27:54+00:00Added an answer on June 15, 2026 at 4:27 am

    This is a hint:

    The user should indicate the end of purchases by entering a negative
    quantity.

    The loop should loop until the user will enter a negative quantity.

    Therefore your loop would look like:

    while quantity > 0:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to simulate a supermarket with the arena to find the proper number
Can I simulate form like behaviour when a user clicks on a simple link?
How do I simulate keystrokes when mouse is clicked in a legacy program. NOTE!
In this program I simulate the gravity. All works but when there is no
I should simulate a p2p protocol (using Java) in which each node initially has
I'm trying to simulate a user click on a Google Map, using API v3,
To simulate enums in PHP I like to use class constants. e.g. class FRUIT
Possible Duplicate: Retrieve (or simulate) full query from PDO prepared statement I can't figure
I have to simulate a USB Device for automation and testing purposes (in Linux).
I have to simulate family tree in prolog. And i have problem of symetrical

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.