# data[].attributes.attachment_link.readable_text
//import javax.swing.ButtonGroup;
/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
 */

/**
 *
 * @author Lusanda.Tsilana
 */
public class IncomeTax extends javax.swing.JFrame {
    


    /**
     * Creates new form IncomeTax
     */
    public IncomeTax() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    //@SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        buttonGroup2 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jRadioButton3 = new javax.swing.JRadioButton();
        jLabel3 = new javax.swing.JLabel();
        btaxincome = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        taxamount = new javax.swing.JTextField();
        ataxincome = new javax.swing.JTextField();
        Recalculate = new javax.swing.JButton();
        jButtonCalculate = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(153, 204, 255));

        jLabel1.setFont(new java.awt.Font("Times New Roman", 1, 36)); // NOI18N
        jLabel1.setText("Tax Calculator");

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jLabel2.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
        jLabel2.setText("How old are you?");

        buttonGroup2.add(jRadioButton1);
        jRadioButton1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jRadioButton1.setText("Under 65");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });

        buttonGroup2.add(jRadioButton2);
        jRadioButton2.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jRadioButton2.setText("Between 65 - 75");
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });

        buttonGroup2.add(jRadioButton3);
        jRadioButton3.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jRadioButton3.setText("Over 75");
        jRadioButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton3ActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
        jLabel3.setText("What is your annual income before tax?");

        btaxincome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btaxincomeActionPerformed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Times New Roman", 0, 18)); // NOI18N
        jLabel4.setText("Results");

        jLabel5.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel5.setText("Yearly income tax          =");

        jLabel6.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N
        jLabel6.setText("Your net annual income  =");

        taxamount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                taxamountActionPerformed(evt);
            }
        });

        ataxincome.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ataxincomeActionPerformed(evt);
            }
        });

        Recalculate.setText("Recalculate");
        Recalculate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RecalculateActionPerformed(evt);
            }
        });

        jButtonCalculate.setText("Calculate");
        jButtonCalculate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonCalculateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addComponent(jRadioButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 50, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jRadioButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(66, 66, 66)
                        .addComponent(jRadioButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addGap(276, 276, 276))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
                                .addComponent(jButtonCalculate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(286, 286, 286)))))
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(176, 176, 176)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 311, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(ataxincome, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(taxamount, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(btaxincome, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(264, 264, 264))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(Recalculate)
                        .addGap(288, 288, 288))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addComponent(jLabel2)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioButton1)
                    .addComponent(jRadioButton2)
                    .addComponent(jRadioButton3))
                .addGap(46, 46, 46)
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addComponent(btaxincome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jButtonCalculate)
                .addGap(54, 54, 54)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(taxamount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ataxincome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(Recalculate)
                .addContainerGap(70, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(266, 266, 266)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(85, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>                        

    
    
    private void ataxincomeActionPerformed(java.awt.event.ActionEvent evt) {                                           
        
    }                                          

    private void taxamountActionPerformed(java.awt.event.ActionEvent evt) {                                          
        
    }                                         

    private void btaxincomeActionPerformed(java.awt.event.ActionEvent evt) {                                           
        
    }                                          

    private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {                                              
       
    }                                             

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                              
        
    }                                             

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                              
       
    }                                             

    private void RecalculateActionPerformed(java.awt.event.ActionEvent evt) {                                            
        
        jRadioButton1.setSelected(false);
        jRadioButton2.setSelected(false);
        jRadioButton3.setSelected(false);
        btaxincome.setText("");
        taxamount.setText("");
        ataxincome.setText("");
    }                                           

    private void jButtonCalculateActionPerformed(java.awt.event.ActionEvent evt) {                                                 
       
        
        int ageGroup = 0;
        
        if(jRadioButton1.isSelected()) {
            ageGroup = 0;
        } else if (jRadioButton2.isSelected()){
            ageGroup = 1;
        } else if (jRadioButton3.isSelected()) {
            ageGroup = 2;
        }
        
      
        double income = Double.parseDouble(btaxincome.getText());
        
       double tax = 0;
       double netIncome = 0;
       
       switch (ageGroup) {
           case 0: // user is under 65
               if(income <= 95750 ) {
                tax = 0;
                netIncome = income;
               }
               
               else if(95751<= income && income <= 237100) {
                   tax = income * 0.18;
                   netIncome = (income - tax) + 17235;

               } else if (237101 <= income && income <= 370500) {
                   tax = 42678 + ((income - 237101) * 0.26);
                   netIncome = (income - tax) + 17235;

               } else if (370501 <= income && income <= 512800) {
                   tax = 77362 + ((income - 370501) * 0.31);
                   netIncome = (income - tax) + 17235;


               } else if (512800 <= income && income <= 673000) {
                   tax = 121475 + ((income - 512800) * 0.36);
                   netIncome = (income - tax) + 17235;


               } else if (673001 <= income && income <= 857900) {
                   tax = 179147 + ((income - 673001) * 0.39);
                   netIncome = (income - tax) + 17235;


               } else if (857901 <= income && income <= 1817000) {
                   tax = 251258 + ((income - 857901) * 0.41);
                   netIncome = (income - tax) + 17235;


                } else if (1817001 <= income) {
                    tax = 644489 + ((income - 1817000) * 0.45);
                    netIncome = (income - tax) + 17235;
                }
                break;



                case 1:  // user is 65 - 75
               if(income <= 148217) {
                   tax = 0;
                   netIncome = income;

               } else if (148218 <= income && income <= 370500) {
                   tax = 42678 + ((income - 237101) * 0.26);
                   netIncome = (income - tax) + 9444;

               } else if (370501 <= income && income <= 512800) {
                   tax = 77362 + ((income - 370501) * 0.31);
                   netIncome = (income - tax) + 9444;


               } else if (512800 <= income && income <= 673000) {
                   tax = 121475 + ((income - 512800) * 0.36);
                   netIncome = (income - tax) + 9444;


               } else if (673001 <= income && income <= 857900) {
                   tax = 179147 + ((income - 673001) * 0.39);                 
                   netIncome = (income - tax) + 9444;

                                                    
               } else if (857901 <= income && income <= 1817000) {
                   tax = 251258 + ((income - 857901) * 0.41);
                   netIncome = (income - tax) + 9444;


                } else if (1817001 <= income) {
                    tax = 644489 + ((income - 1817000) * 0.45);
                    netIncome = (income - tax) + 9444;
                }
                System.out.println(netIncome);
                break;



                case 2:  // user is over 75
               if(income <= 165689) {
                   tax = 0;
                   netIncome = income;

               } else if (165690<= income && income <= 370500) {
                   tax = 42678 + ((income - 237101) * 0.26);
                   netIncome = (income - tax) + 3145;

               } else if (370501 <= income && income <= 512800) {
                   tax = 77362 + ((income - 370501) * 0.31);
                   netIncome = (income - tax) + 3145;


               } else if (512800 <= income && income <= 673000) {
                   tax = 121475 + ((income - 512800) * 0.36);
                   netIncome = (income - tax) + 3145;


               } else if (673001 <= income && income <= 857900) {
                   tax = 179147 + ((income - 673001) * 0.39);
                   netIncome = (income - tax) + 3145;


               } else if (857901 <= income && income <= 1817000) {
                   tax = 251258 + ((income - 857901) * 0.41);
                   netIncome = (income - tax) + 3145;


                } else if (1817001 <= income) {
                    tax = 644489 + ((income - 1817000) * 0.45);
                    netIncome = (income - tax) + 3145;
                }
                break;

                
            }      
            
                   taxamount.setText(String.format("%.2f", tax));
                   ataxincome.setText(String.format("%.2f", netIncome));
       }
               
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        
        
     
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(IncomeTax.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(IncomeTax.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(IncomeTax.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(IncomeTax.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new IncomeTax().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton Recalculate;
    private javax.swing.JTextField ataxincome;
    private javax.swing.JTextField btaxincome;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButtonCalculate;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JRadioButton jRadioButton3;
    private javax.swing.JTextField taxamount;
    // End of variables declaration                   
}


# data[].attributes.headline
day 2. activity 2: email validation using regEx

# data[].attributes.subject
day 2. activity 2: email validation using regEx

# data[].attributes.attachment_link.readable_text
import re 
pattern = "[a-zA-Z0-9]+@[a-zA-Z]+\.(com|edu|net)"
email_address = input("Enter email address:")

if(re.search(pattern, email_address)):
    print(f"{email_address} is valid")

else:
    print(f"{email_address} is invalid")

# data[].attributes.headline
day1: activity. inheritance & private variables

# data[].attributes.subject
day1: activity. inheritance & private variables

# data[].attributes.attachment_link.readable_text
import string
import secrets

symbols = "!@#$%^&*"
alphabet = string.ascii_letters + string.digits  
password = ''.join(secrets.choice(alphabet) for i in range(12))
recess = "break line"
print(password)
print(recess)

import random
lower = "abcdefghijklmnopqrstuvwxyz"
upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
numbers = "0123456789"
symbols = "!@#$%^&*"

string = lower + upper + numbers + symbols
length = 12
password = "".join(random.sample(string,length))

print("Your new password is:" + password)

# data[].attributes.attachment_link.readable_text
class Employee:
    pass

emp_1 = Employee()
emp_2 = Employee()

print(emp_1)
print(emp_2)

emp_1.first = 'Corey'
emp_1.last = 'Smith'
emp_1.email = 'sanda.tsilana@gmail.com'
emp_1.pay = 50000

print(emp_1.email)
print(emp_2.email)

# data[].attributes.attachment_link.readable_text
import math
#importing math because there's a math function to t=the power of 2 at line 22 and line 28

list2=['Lusanda','Sima','Mohammed','Mandisa','Lizzy','Asisipho', 'Michelle', 'Nellie', 'Sima']
print("Original Cohort: ",list2)

# Count occurrences using count()
print("How many Sima's do we have in our cohort? : ",list2.count('Sima'))


list2.insert(0, 'Yaya')
print("Addition of another candidate:", list2 )



list2.reverse()
print('Reverse of the list', list2)

list2.append('Sydney')
print("Second Addition of candidate:", list2)

list2.pop()
print("Removal the last candidate to be added:", list2)

squares = []
for x in range(10):
    squares.append(x**2)
    print(squares)

recess = ['0', '0', '0']
print(recess)

squares = list(map(lambda x: x**2, range(10)))
print(squares)

var_list = [-5, -3, -1, 0, 7, 11]
mutliples = [x*2 for x in var_list]
print("mutliples:", mutliples)

#to filter negative numbers
positive_numbers = [x<0]
print("positive numbers only:", var_list)

matrix = [
    [1, 2, 3, 4],
    [5, 6, 7, 8],
    [9, 10, 11, 12],
]
print(matrix)

#tuples are variables with multiple values eg var = (10, 'Jessica', 35.75, [20, 1, 11])

#I see with the del() statement, it is similar to the pop method. 
#difference is that pop, you remove that piece of data by using the name of that item etc
#del statement does the same thing but by identifying the index(position) of that item in the list

a = [-5, -3, -1, 0, 7, 11]
del a[0]
print(a)
u = [-5, a, 7, 209, 301]
print(u)

#activity 1
# maybe build a database with each students information - name, email, parents info, address. 
#instead of having that data in files. we can have it in a database. Every year, the 
#information is carried over or deleted if a student should leave the school etc.
#will do more research understanding what more I can.

# data[].attributes.attachment_link.readable_text

while(True):
    bank_userInput = str(input("Would you like to make a transaction? 'Yes' or 'No'"))


    if(bank_userInput.lower()=="yes"):
    

        try:
            with open("./Data.txt", 'r+') as Bank_Data:
                data= Bank_Data.readlines()
            
                balanceVal = float(data[3].split()[2])

                bank_userInput = str(input("Would you like to make a deposit or withdrawal: 'Withdrawal' or 'Deposit'"))

                if(bank_userInput.lower()=="withdrawal"):

                    bank_userInput = float(input("Please Enter the amount you would like to withdraw: "))
                

                    if(balanceVal== 0.0 or balanceVal<bank_userInput):

                        print("You do not have sufficient funds to make this withdrawal")

                    else:
                        try:
                            with open("./Log.txt", 'a') as Log_transactions:
                            
                                Log_transactions.write(f"Withdrawal made of R{bank_userInput}\n")
                                new_balance = balanceVal- bank_userInput
                                data[3] = f"balance : {new_balance}"
                                Bank_Data.seek(0)
                                Bank_Data.writelines(data)
                    
                        except(FileNotFoundError):
                        
                            print("cannot open file")

                elif(bank_userInput.lower()=="deposit"):
                    bank_userInput = float(input("Please Enter the amount you would like to Deposit: "))
                
                    try:
                        with open("./Log.txt", 'a') as Log_transactions:
                            
                            Log_transactions.write(f"Deposit made of R{bank_userInput}\n")
                    
                    except(FileNotFoundError):

                            print("cannot open file")
                print(f"��our bank balance is {new_balance}")

            
        except(FileNotFoundError):
            print("cannot open file!!")


    elif(bank_userInput.lower()=="no"):
        print("Thank you have a nice Day!!!")
        break

# data[].attributes.attachment_link.readable_text
import math

#while(True):
userInput = str(input("Choose either 'investment' or 'bond' from the menu below to proceed:\ninvestment - to calculate the amount of interest you'll earn on interest\nbond       - to calculate the amount you'll have to pay on a loan\n"))

if(userInput.lower()=="investment"):
    
        deposit = float(input("Please input the amount of money you wish to deposit:"))

        userInput = str(input("Would you like simple or compound interest?"))

        if(userInput.lower()=="compound"):

                interestRate = float(input("What is the interest rate?"))

                time = float(input("How many years do you wish to invest?"))

                total_amount = float(deposit * math.pow((1+((interestRate/100) / 12)),time))

                total_amount =  "%.2f" % total_amount  

                print(f"The total value of your investment will be: {total_amount}")

        if(userInput.lower()=="simple"):

                interestRate = float(input("What is the interest rate?"))

                time = float(input("How many years do you wish to invest?"))

                total_amount = float(deposit * (1 + (((interestRate/100) / 12))*time))

                total_amount =  "%.2f" % total_amount  

                print(f"The total value of your investment will be: {total_amount}")

#else:
#       print("Invalid input")

elif(userInput.lower()=="bond"):
        
        present_value_house = float(input("Please input the present value of the house:"))

        repayment_period = int(input("Please input the duration of months over which the bond will be repaid:"))

        interestRateB = float(input("What is the interest rate?"))

        bond_repayment = ((((interestRateB/100)/12)/12)*present_value_house)/(1 - (1+((interestRateB/100)/12)/12)**(-repayment_period))

        bond_repayment = "%.2f" % bond_repayment

        print(f"The total repayment will be, R{bond_repayment} per month")

else:
        print("Invalid input")


