jeudi 28 septembre 2017

Python - My IF statement does not run with while loop and array

This is my project for my part and my part does not seem to be working with others' function.

Below is the code for my part. If there's some kind of syntax error with the if statement I'm not seeing it. Does anyone know what's going on?

  def calculation(uniname, programme, course):
        cls()
        programme = {"Foundation","Diploma"}
        course = {"Business","Engineering","Information Technology"}

        fob_fee = [700.00, 400.00, 1430.00, 13200.00, 15180.00, 23664.00]
        foe_fee = [700.00, 400.00, 1430.00, 13200.00, 15840.00, 25340.00] 
        fit_fee = [700.00, 400.00, 1430.00, 13200.00, 15180.00, 23664.00]  
        dob_fee = [700.00, 400.00, 19780.00, 13200.00, 18000.00, 47987.00] 
        doe_fee = [700.00, 400.00, 19780.00, 13200.00, 21600.00, 46267.00] 
        dit_fee = [700.00, 400.00, 19780.00, 13200.00, 19200.00, 46267.00] 
        hostelfee = [720.00, 420.00, 2640.00, 3120.00, 3000.00, 10080.00]

        uni = 0
        uniname = uni
        uni = {"a","b","c","d","e","f"}
        while uniname:
            if (uniname==uni and programme=="Foundation" and course=="Business"):
                if choice == "yes" or "1":
                    total_fees = fob_fee[i] + hostelfee[hi]
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Foundation")
                    print ("Course chosen: Business")
                    print ("Total estimated fees with accommodation (1 year): RM "),float(total_fees)
                    print "|-------------------------------------------------------------------------|"
                elif choice == "no" or "2":
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Foundation")
                    print ("Course chosen: Business")
                    print ("Total fees (1 year): RM "),fob_fee[i]
                    print "|-------------------------------------------------------------------------|"
                else:
                    print "Please enter a valid input"

            elif (uniname==uni and programme=="Foundation" and course=="Engineering"):
                if choice == "yes" or "1":
                    total_fees = foe_fee[i] + hostelfee[hi]
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Foundation")
                    print ("Course chosen: Engineering")
                    print ("Total estimated fees with accommodation (1 year): RM "),float(total_fees)
                    print "|-------------------------------------------------------------------------|"
                elif choice == "no" or "2":
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Foundation")
                    print ("Course chosen: Engineering")
                    print ("Total fees (1 year): RM "),foe_fee[i]
                    print "|-------------------------------------------------------------------------|"
                else:
                    print "Please enter a valid input"

            elif (uniname==uni and programme=="Foundation" and course=="Information Technology"):
                if choice == "yes" or "1":
                    total_fees = fit_fee[i] + hostelfee[hi]
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Foundation")
                    print ("Course chosen: Information Technology")
                    print ("Total estimated fees with accommodation (1 year): RM "),float(total_fees)
                    print "|-------------------------------------------------------------------------|"
                elif choice == "no" or "2":
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Foundation")
                    print ("Course chosen: Information Technology")
                    print ("Total fees (1 year): RM "),fit_fee[i]
                    print "|-------------------------------------------------------------------------|"
                else:
                    print "Please enter a valid input"

            elif (uniname==uni and programme=="Diploma" and course=="Business"):
                if choice == "yes" or "1":
                    total_fees = dob_fee[i] + hostelfee[hi]
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Diploma")
                    print ("Course chosen: Business")
                    print ("Total estimated fees with accommodation (1 year): RM "),float(total_fees)
                    print "|-------------------------------------------------------------------------|"
                elif choice == "no" or "2":
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uniname
                    print ("Programme chosen: Diploma")
                    print ("Course chosen: Business")
                    print ("Total fees (1 year): RM "),dob_fee[i]
                    print "|-------------------------------------------------------------------------|"
                else:
                    print "Please enter a valid input"

            elif (uniname==uni and programme=="Diploma" and course=="Engineering"):
                if choice == "yes" or "1":
                    total_fees = doe_fee[i] + hostelfee[hi]
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Diploma")
                    print ("Course chosen: Engineering")
                    print ("Total estimated fees with accommodation (1 year): RM "),float(total_fees)
                    print "|-------------------------------------------------------------------------|"
                elif choice == "no" or "2":
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Diploma")
                    print ("Course chosen: Engineering")
                    print ("Total fees (1 year): RM "),doe_fee[i]
                    print "|-------------------------------------------------------------------------|"
                else:
                    print "Please enter a valid input"

            elif (uniname==uni and programme=="Diploma" and course=="Information Technology"):
                if choice == "yes" or "1":
                    total_fees = dit_fee[i] + hostelfee[hi]
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Diploma")
                    print ("Course chosen: Information Technology")
                    print ("Total estimated fees with accommodation (1 year): RM "),float(total_fees)
                    print "|-------------------------------------------------------------------------|"
                elif choice == "no" or "2":
                    print "|-------------------------------------------------------------------------|"
                    print "Your result : "
                    print ("University chosen: "),uni
                    print ("Programme chosen: Diploma")
                    print ("Course chosen: Information Technology")
                    print ("Total fees (1 year): RM "),dit_fee[i]
                    print "|-------------------------------------------------------------------------|"
                else:
                    print "Please enter a valid input"
                uni +=1

        print "|-------------------------------------------------------------------------|"
        print "|                           Accommodation                                 |"
        print "|-------------------------------------------------------------------------|"
        choice = raw_input("Do you required on-campus accommodation? 1.Yes  2.No\n-->")
    Menu()

The below part is working but when I choose 1 or 2, the program just exit.

All the if statement the program cannot run.

Aucun commentaire:

Enregistrer un commentaire