Convert to C++

Can anyone convert this code to a program that uses namespace std and iostream and fstream header files.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import filestore
import time
import datetime
def postbank():                                                                         
    print ("Welcome to PostBank, We care for you\n")                                    
    prompt=int(raw_input("""To open a new bank account, Press 1\n"""+                                 
                        """To access your existing account & transact press 2\n"""))    
    if prompt==1:                                                                       
        cus=BankAccount()#creates a new customer profile                                
    elif prompt==2:                                                                     
        cus=ReturnCustomer()#checks for existing customer                               
    else:                                                                               
        print "You have pressed the wrong key, please try again"                        
        postbank()                                      
"""Class for a bank account"""
    type="Normal Account"
    def __init__(self):
        ##calls functions in the module filestore
        self.username, self.userpassword, self.balance=filestore.cusaccountcheck()
        print ("Thank you %s, your account is set up and ready to use,\n a 100 pounds has been credited to your account" %self.username)
        time.sleep(2)
        self.userfunctions()
  

def userfunctions(self):
        print("\n\nTo access any function below, enter the corresponding key")
        print ("""To:
check Balance, press B.
deposit cash,  press D.
withdraw cash, press W.
Delete account press X.
exit service,  press E\n
:"""),
        ans=raw_input("").lower()
        if ans=='b':
self.passcheck()
            self.checkbalance()
        elif ans=='d':
            self.passcheck()
            self.depositcash()
        elif ans=='w':
            self.passcheck()
            self.withdrawcash()
        elif ans=='x':
            print ("%s, your account is being deleted"%self.username)
            time.sleep(1)
            print ("Minions at work")
            time.sleep(1)
            filestore.deleteaccount(self.username)
            print ("Your account has been successfuly deleted, goodbye")
        elif ans=='e':
            print ("Thank you for using PostBank Services")
            time.sleep(1)
            print ("Goodbye %s" %self.username)
            exit()

        else:
            print "No function assigned to this key, please try again"
            self.userfunctions()
def checkbalance(self):
        date=datetime.date.today()
        date=date.strftime('%d-%B-%Y')
        self.working()
        print ("Your account balance as at {} is {}").format(date, self.balance)
        self.transact_again()

    def withdrawcash(self):
        amount=float(raw_input("::\n Please enter amount to withdraw\n: "))
        self.balance-=amount
        self.working()
        print ("Your new account balance is %.2f" %self.balance)
        print ("::\n")
        filestore.balupdate(self.username, -amount)
        self.transact_again()

    def depositcash(self):
        amount=float(raw_input("::\nPlease enter amount to be deposited\n: "))
        self.balance+=amount
        self.working()
        print ("Your new account balance is %.2f" %self.balance)
        print ("::\n")
        filestore.balupdate(self.username, amount)
        self.transact_again()
def transact_again(self):
        ans=raw_input("Do you want to do any other transaction? (y/n)\n").lower()
        self.working()
        if ans=='y':
            self.userfunctions()
        elif ans=='n':
            print ("Thank you for using PostBank we value you. Have a good day")
            time.sleep(1)
            print ("Goodbye {}").format(self.username)
            exit()
        elif ans!='y' and ans!='n':
            print "Unknown key pressed, please choose either 'N' or 'Y'"
            self.transact_again()


    def working(self):
        print("working"),
        time.sleep(1)
        print ("..")
        time.sleep(1)
        print("..")
        time.sleep(1)
def passcheck(self):
        """prompts user for password with every transaction and counterchecks it with stored passwords"""
        b=3
        while b>0:
            ans=raw_input("Please type in your password to continue with the transaction\n: ")
            if ans==self.userpassword:
                return True


            else:
                print "That is the wrong password"
                b-=1
                print ("%d more attempt(s) remaining" %b)

        print ("Account has been freezed due to three wrong password attempts,\n contact your bank for help, bye bye")
        time.sleep(1)
        print ("...")
        time.sleep(1)
        print("...")
        time.sleep(1)

        exit()
type="Normal Account"
    def __init__(self):
        self.username, self.userpassword, self.balance=filestore.oldcuscheck()
        self.userfunctions()

postbank()
Is it Python? Before doing any work, have you already tested if it woks? ‘Translating’ a bad working code would be pointless, I think.
And please could you clarify if it is an assignment or not?
Topic archived. No new replies allowed.