Mein erstes kleines Programm...
Verfasst: Montag 23. Februar 2015, 21:11
... will nicht ganz funktionieren. Ich dachte mir, ich programmiere mir mal ein kleines Kalkulationsprogramm. Hier der Code:
Ich wollte die Methoden in die Klasse unterbringen. Vorher hatte ich es ohne Klasse, sondern nur als Funktionen laufen. Da hat es auch funktioniert. Also, die Formeln für die Berechnungen sind richtig. Jedoch wird nicht mal die start(self)-Methode gestartet, in welcher der Anwender gefragt wird, welches Feature es starten möchte. Bestimmt habe ich was ganz elementares übersehen. Kann mir jemand weiterhelfen?
Code: Alles auswählen
# -*- coding: utf-8 -*-
from __future__ import division
from decimal import Decimal
import sys
# Informationen zum Programm
ProduktName = "Kalkulationsschema fuer den Einzelhandel"
CopyRight = "©"
Autor = "Sophus"
Jahr = "2014"
Version = "Built 0.1"
DankSagung = "Mitgliedern des deutschen Python-Forum"
URL_Forum ="http://www.python-forum.de/"
Feature1 = "Beschaffungskalkulation(Vorwaerts)"
Feature2 = "Beschaffungskalkulation(Rueckwaerts)"
Feature3 = "Differenzkalkulation"
Feature4 = "Absatzkalkulation"
print "================================ Hilfe ================================="
print " Tastenkuerzel: - E (Programm beenden)"
print ""
print "================================ Info =================================="
print " Willkommen bei " + "'" + ProduktName + "'" + " ( " + Version + " )"
print " Dieses Programm wurde von " + CopyRight + " " + Autor + "(" + Jahr + ") geschrieben."
print ""
print "================================ Danksagung ============================"
print " An dieser Stelle moechte ich mich bei den "
print " "+ DankSagung + " bedanken."
print " URL: " + URL_Forum
print ""
print "================================ Menu =================================="
print " Folgende Features sind enthalten:"
print " (1)" + Feature1
print " (2)" + Feature2
print " (3)" + Feature3
print " (4)" + Feature4
print ""
print "================================ Programm =============================="
print ""
class calcu (object):
def __init__(self):
# Anwender soll sich ein Feature (Methode) aussuchen
def start(self):
VarDict ={"1":Feature1, "2":Feature2, "3": Feature3, "4": Feature4}
Eingabe = raw_input(""" Waehlen Sie ein Feature aus dem Menu, indem sie die entsprechende
Zahl eingeben! """)
MyString = ' Sie haben sich fuer das folgende Feature entschieden: '
print MyString + VarDict[Eingabe]
if Eingabe == "1":
BKV() # Beschaffungskalkulation(Vorwaerts)-Methode aufrufen
if Eingabe == "2":
BKVR() # Beschaffungskalkulation(Rueckwaerts)-Methode aufrufen
if Eingabe == "3":
DK() # Differenzkalkulation-Methode aufrufen
if Eingabe == "4":
AK() # Absatzkalkulation-Methode aufrufen
if Eingabe >= 4: #Keine Methode aufrufen
print "Falsch"
def BKV(self): # Beschaffungskalkulation(Vorwaerts)
print ""
print " Die " + Feature1 + " wurde gestartet."
print ""
LP = float(raw_input(" Listenpreis: "))
LR = float(raw_input(" - Lieferantenrabatt (%): "))
ZKP = Decimal(LP-LP*LR/100)
R_ZKP = round(ZKP, 2)
print " = Zieleinkaufspreis: " + str(R_ZKP) + " Euro"
print "-----------------------"
LSK = float(raw_input (" - Lieferantenskonto (%) "))
BKP = Decimal(R_ZKP-R_ZKP*LSK/100)
R_BKP = round(BKP, 2)
print " = Bareinkaufspreis: " + str(R_BKP) + " Euro"
print "-----------------------"
BZK= float(raw_input("+ Bezugskosten "))
BZP = Decimal(BZK+R_BKP)
R_BZP = round(BZP, 2)
print " = Einstandspreis (Bezugspreis) " + str(R_BZP) + " Euro"
print "-----------------------"
GMK = float(raw_input(" + Gemeinkosten / Handlungskosten (%): "))
SKP = Decimal(R_BZP+(GMK*R_BZP)/100)
R_SKP = round(SKP, 2)
print " = Selbstkosten: " + str(R_SKP) + " Euro"
print "-----------------------"
GZS = float(raw_input(" + Gewinnzuschlag (%): "))
BVKP = Decimal(R_SKP+(R_SKP*GZS)/100)
R_BVKP = round(BVKP, 2)
print " = Barverkaufspreis: " + str(R_BVKP) + " Euro"
print "-----------------------"
KSK = float(raw_input(" + Kundenskonto (%): "))
VP = float(raw_input(" + Vertreterprovision (%): "))
KSK_Zwsichenschritt = Decimal(R_BVKP*KSK/(100-KSK-VP))
R_KSK_Zwsichenschritt = round(KSK_Zwsichenschritt, 2)
VP_Zwischenschritt = Decimal(R_BVKP*VP/(100-KSK-VP))
R_VP_Zwischenschritt = round(VP_Zwischenschritt, 2)
ZVP = Decimal(R_BVKP+(R_KSK_Zwsichenschritt+R_VP_Zwischenschritt))
R_ZVP = round(ZVP, 2)
print " = Zielverkaufspreis: " +str(R_ZVP) + " Euro"
print "-----------------------"
KR = float(raw_input(" + Kundenrabatt: "))
LVKP_netto = Decimal(R_ZVP/(100-KR)*100)
R_LVKP_netto = round(LVKP_netto, 2)
print " = Listenverkaufspreis (netto): " + str(R_LVKP_netto) + " Euro"
print "-----------------------"
UST = float(raw_input(" + Umsatzsteuer (%): "))
LVKP_brutto = Decimal(R_LVKP_netto+R_LVKP_netto/100*UST)
R_LVKP_brutto = round (LVKP_brutto, 2)
print " = Listenverkaufspreis (brutto): " + str(R_LVKP_brutto) + " Euro"
print "======================="
def BKVR(self): # Beschaffungskalkulation(Rueckwaerts)
print ""
print """ HINWEIS: Dieses Feature ist noch in Arbeit. Bei der naechsten
Aktualisierung wird das von Ihnen gewuenschte Feature freigeschalten."""
def DK(self): # Differenzkalkulation
print ""
print " Die " + Feature3 + " wurde gestartet."
print ""
LP = float(raw_input(" Listenpreis: "))
LR = float(raw_input(" - Lieferantenrabatt (%): "))
ZKP = float(Decimal(LP-LP*LR/100))
R_ZKP = round(ZKP, 3)
print " = Zieleinkaufspreis: " + str(R_ZKP) + " Euro"
print "-----------------------"
LSK = float(raw_input (" - Lieferantenskonto (%) "))
BKP = float(Decimal(ZKP-ZKP*LSK/100))
R_BKP = round(BKP, 3)
print " = Bareinkaufspreis: " + str(R_BKP) + " Euro"
print "-----------------------"
BZK= float(raw_input("+ Bezugskosten "))
BZP = float(Decimal(BZK+BKP))
R_BZP = round(BZP, 3)
print " = Einstandspreis (Bezugspreis) " + str(R_BZP) + " Euro"
print "-----------------------"
GMK = float(raw_input(" + Gemeinkosten / Handlungskosten (%): "))
SKP = float(Decimal(BZP+(GMK*BZP)/100))
R_SKP = round(SKP, 3)
print " = Selbstkosten: " + str(R_SKP) + " Euro"
print "======================="
print ""
LVKP_brutto = float(raw_input(" Listenverkaufspreis (brutto): "))
UST = float(raw_input(" - Umsatzsteuer (%): "))
LVKP_netto = float((LVKP_brutto/(100+UST))*100)
R_LVKP_netto = round (LVKP_netto, 2)
print " = Listenverkaufspreis (netto): " + str(R_LVKP_netto) + " Euro"
print "-----------------------"
KR = float(raw_input(" + Kundenrabatt: "))
ZVK = float(Decimal(LVKP_netto/100*(100-KR)))
R_ZVK = round(ZVK, 2)
print " = Zielverkaufspreis " + str(R_ZVK)
print "-----------------------"
KSK = float(raw_input(" + Kundenskonto: "))
BVKP = float(Decimal(ZVK/100*(100-KSK)))
R_BVKP = round(BVKP, 2)
print " = Barverkaufspreis: " + str(R_BVKP)
print "-----------------------"
GZS = float(Decimal(R_SKP-R_BVKP))
R_GZS = round(GZS, 2)
GZS_in_Prozent = float(Decimal((R_GZS*100)/R_SKP))
R_GZS_in_Prozent = round(GZS_in_Prozent, 2)
print " + Gewinnzuschlag: " + str(R_GZS) + " Euro " + "(" + str(R_GZS_in_Prozent) + "%)"
print "======================="
def AK(self): # Absatzkalkulation
print ""
print """ HINWEIS: Dieses Feature ist noch in Arbeit. Bei der naechsten
Aktualisierung wird das von Ihnen gewuenschte Feature freigeschalten."""