473,587 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Expense calculator

Deathwing
32 New Member
Hi everyone one I'm playing around with trying to make an expense calculator.
I would like it so that the user can keep enter expenses until they have no more expenses. Then I would like for the program to give the users total expenses then subtract this from their total income and inform them how much they have left after monthly expenses. Any ideas ? this is what I've come up with thus far.
Expand|Select|Wrap|Line Numbers
  1. # Expense calculator
  2. # This program calculates your total monthly expenses
  3.  
  4.  
  5. #print"\a"
  6.  
  7. print\
  8.        """
  9.                         #-----------------#
  10.                         |Montly Expense   |
  11.                         |Calculator 1.0   |
  12.                         #-----------------#
  13.  
  14.  Welcome to Monthly Expense Calculator 1.0 this calculator
  15.  will ask you a series of questions relating to your monthly
  16.  expenses. It will then calculate your total montly income
  17.  against your expenses and tell you how much of  your take
  18.  home pay you are spending.
  19.        """
  20.  
  21. print " You have the following options:"
  22.  
  23. print "\n To enter an expense type '1' otherwise type '2' for no more expenses."
  24.  
  25. options = ( 'espense = 1', 'noexpense = 2')
  26.  
  27. while True:
  28.  
  29.     choice = int(raw_input("\nWould you like to enter a monthly expense?"))
  30.  
  31.     if choice == 1:
  32.         expense = (raw_input("\nEnter expense name"))
  33.         cost = float(raw_input("\nEnter total monthly cost of this expense."))
  34.     elif  choice == 2:
  35.         raw_input("\nPress enter to exit.")
  36.         break
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
Apr 19 '07 #1
5 5753
ilikepython
844 Recognized Expert Contributor
Hi everyone one I'm playing around with trying to make an expense calculator.
I would like it so that the user can keep enter expenses until they have no more expenses. Then I would like for the program to give the users total expenses then subtract this from their total income and inform them how much they have left after monthly expenses. Any ideas ? this is what I've come up with thus far.
Expand|Select|Wrap|Line Numbers
  1. # Expense calculator
  2. # This program calculates your total monthly expenses
  3.  
  4.  
  5. #print"\a"
  6.  
  7. print\
  8.        """
  9.                         #-----------------#
  10.                         |Montly Expense   |
  11.                         |Calculator 1.0   |
  12.                         #-----------------#
  13.  
  14.  Welcome to Monthly Expense Calculator 1.0 this calculator
  15.  will ask you a series of questions relating to your monthly
  16.  expenses. It will then calculate your total montly income
  17.  against your expenses and tell you how much of  your take
  18.  home pay you are spending.
  19.        """
  20.  
  21. print " You have the following options:"
  22.  
  23. print "\n To enter an expense type '1' otherwise type '2' for no more expenses."
  24.  
  25. options = ( 'espense = 1', 'noexpense = 2')
  26.  
  27. while True:
  28.  
  29.     choice = int(raw_input("\nWould you like to enter a monthly expense?"))
  30.  
  31.     if choice == 1:
  32.         expense = (raw_input("\nEnter expense name"))
  33.         cost = float(raw_input("\nEnter total monthly cost of this expense."))
  34.     elif  choice == 2:
  35.         raw_input("\nPress enter to exit.")
  36.         break
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
I'm not exactly sure what you are saying but you might be able to use a dictionary to store the data of the expenses.For example, enter the expense name into the key and make the value the monthly cost.
Apr 19 '07 #2
ghostdog74
511 Recognized Expert Contributor
using dictionaries might not be suitable for this application as users might want to save data on disk. so another way is to use pickle/shelve or dbm databases. (other others).
Apr 19 '07 #3
bartonc
6,596 Recognized Expert Expert
using dictionaries might not be suitable for this application as users might want to save data on disk. so another way is to use pickle/shelve or dbm databases. (other others).
I thought that pickling worked on dictionaries. Am I wrong about this?
Apr 20 '07 #4
ghostdog74
511 Recognized Expert Contributor
I thought that pickling worked on dictionaries. Am I wrong about this?
no, you are not wrong. what i meant in my previous post is, if OP uses just pure dictionaries, whatever data modification to expenses stored in dictionaries will be gone once the program exits. So its good to use some [ pickling/shelving/dbm/files ] to save information to disk so that the expenses can be "remembered " next time the application is used.
Apr 20 '07 #5
Deathwing
32 New Member
Thanks guys I'll look into your suggestions. I appreicate the help.
Apr 23 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
7295
by: Rafael | last post by:
Hi Everyone, I need some help with my calculator program. I need my program to do 2 arguments and a 3rd, but the 3rd with different operators. Any help would be great. Here is my code.... #include <stdio.h> #include <stdlib.h>
3
5199
by: Paul | last post by:
I want to make a simple calculator program but dont know where to get started. This is not GUI but a simple terminal program. It would get input like this Enter number: 5 + 10
4
3129
by: tlyczko | last post by:
Hello, I have read about currency calculations, etc. in this newsgroup, and I understand that currency math will be sufficiently accurate for what I need to do for a mileage/expense report. Where I'm stuck is what data type etc. I should use for the mileage distance number -- single?? decimal?? for the amount of mileage distance traveled, to two decimal places maximum, but allowing for no decimals or one decimal place or two decimal...
24
6313
by: firstcustomer | last post by:
Hi, Firstly, I know NOTHING about Javascript I'm afraid, so I'm hoping that someone will be able to point me to a ready-made solution to my problem! A friend of mine (honest!) is wanting to have on his site, a Javascript Calculator for working out the cost of what they want, for example: 1 widget and 2 widglets = £5.00
19
4004
by: TexasNewbie | last post by:
This was originally just a calculator without a decimal point. After I added the decimal, it now tells me invalid second number. //GUI Calculator Program import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*;
9
3801
Deathwing
by: Deathwing | last post by:
Hey everyone, I have written a code that figures out a users total montly expenses. I have it working except for the fact that it does not add up their cumulative entries. For example, the code ask the user to enter their net montly income then an expense name and the cost of this expense it then ask them if they have another expense to enter if they hit no it calculates their monthly expenses by subtracting their net income from the expense and...
3
11844
by: itsmichelle | last post by:
This is a very primative code of a java swing calculator. I have assigned all the number buttons and the operator buttons and I can add, subtract, multiply, and divide two numbers together. However, my teacher wants the operators to follow the algebraic order of operations by chaining multiple operations. Such as, 7 + 4 * 2= 15. The operatorListener is the ActionListener for the operator buttons. Thanks for any help you can give me. ...
3
2884
by: mandy335 | last post by:
public class Calculator { private long input = 0; // current input private long result = 0; // last input/result private String lastOperator = ""; // keeps track of the last operator entered /* Digit entered as integer value i * Updates the value of input accordingly to (input * 10) + i */
7
3170
by: MNNovice | last post by:
Please forgive me for this is a long request. I am designing a DB to capture expenses related to Federal Grants and to generate appropriate reports. Each grant starts with a Notice of Grant Award (NOGA) which has 7 parts. Grant Number Grant Title Amendment Number Revision Number Fund Information Apportion Year (AY), could be a single year or multiple year. Grant Amount associated with each Apportion Year.
0
7924
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7854
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.