Professional Documents
Culture Documents
Park 1
Park 1
Park 1
Problem statementThe new bank, "YoursPay", has a list of N customers' bank account balances. The
list consists of both positive and negativebalances. The positive balance signies the current year's
customers and the negative balance signies last year's customers. The bankhas decided to offer
shortlisted customers credit scores to their credit cards. The credit score will be the sum of the two
balances fromthe list with the smallest product when multiplied. If the credit score is positive then
the credit will be provided to the current year'scustomer, otherwise, it will go to the last year's
customer
Problem Statement Analysis:
The problem involves processing a list of bank account balances for both current and last year's
customers. The task is to determine the credit scores for each customer based on the sum of the two
balances with the smallest product when multiplied. The credit score is used to decide whether to
provide credit to the current year's customer or the last year's customer.
1. List of Balances:
The input consists of a list of N customers' bank account balances, with positive balances
representing current year customers and negative balances representing last year's
customers.
2. Credit Score Calculation:
The credit score is determined by finding the two balances with the smallest product when
multiplied. The sum of these two balances becomes the credit score for that customer.
3. Decision Rule:
If the credit score is positive, credit is provided to the current year's customer. Otherwise,
credit goes to the last year's customer.
1. Input Processing:
Read and process the list of N customers' bank account balances.
2. Balances Comparison:
For each customer, identify pairs of balances and calculate their product. Keep track of the
pair with the smallest product.
3. Credit Score Calculation:
Calculate the credit score as the sum of the balances in the identified pair.
4. Decision Making:
Based on the credit score, determine whether to provide credit to the current year's customer
or the last year's customer.
5. Output:
Display or output the credit scores and the corresponding decisions for each customer.
Example:
Suppose the list of balances is [5, -3, 8, -2]. The pairs and their products are:
In this example, the pair (5, -2) has the smallest product (-10), so the credit score for the first
customer is 5 + (-2) = 3. Since the credit score is positive, credit will be provided to the current year's
customer.
Note:
Additional details about the problem, such as the desired output format and any constraints, would
be essential for a more precise solution
Python code:
def calculate_credit_scores(balances):
# Iterate through pairs and find the one with the smallest product
best_product = product
credit_score = sum(best_pair)
decision = "Credit provided to current year's customer" if credit_score > 0 else "Credit provided to last
year's customer"
def input_balances():
try:
balances_list = []
for i in range(num_customers):
balances_list.append(balance)
return balances_list
Question No: 2
Problem statement:
The MNC 'Softcomp' had a security breach recently and company offcials have decided to change
the system password. The system password is in string format tagged a-z or A-Z. To change the password
the ocials will simply convert the lowercase characters of theold password to uppercase, and uppercase
characters of the old password to lowercase.Write an algorithm to display the new password. If no such
password is possible display null
Certainly! Below is a simple algorithm in pseudocode to achieve the described password transformation:
Algorithm: ChangePassword
Input:
- oldPassword (string)
Output:
- newPassword (string)
oldPassword = "SecuriTy123"
newPassword = ChangePassword(oldPassword)
Display newPassword
This algorithm iterates through each character of the old password, converts lowercase letters to
uppercase, and uppercase letters to lowercase. If the new password is different from the old password, it
is considered the updated password; otherwise, the new password is set to null.
Note: The actual implementation of this algorithm in a programming language (like Python, Java, etc.)
would involve specific functions for converting case and handling strings. If you have a preference for a
specific programming language, I can provide a code example in that language.
Python:
def change_password(old_password):
new_password = ""
if char.islower():
new_password += char.upper()
elif char.isupper():
new_password += char.lower()
else:
new_password += char
if new_password != old_password:
return new_password
else:
return None
# Example usage
new_password = change_password(old_password)
else:
This Python program defines a function change_password that iterates through each character of the old
password, converts lowercase letters to uppercase, and uppercase letters to lowercase. If the new
password is different from the old password, it is returned; otherwise, None is returned. The program then
takes user input for the old password, applies the function, and prints the new password or "No change in
password. The new password is null." based on the result.