Computer Science, asked by sandeeptinku432, 3 months ago

The new bank, "YoursPay", has a list of N
customers' bank account balances. The list
consists of both positive and negative balances.
The positive balance signifies the current year's
customers and the negative balance signifies
last year's customers. The bank has decided to
offer shortlisted customers credit scores to
their credit cards. The credit score will be the
sum of the two balances from the list with the
smallest product when multiplied. If the credit
score is positive then the credit will be provided
to the current year's customer, otherwise it will
go to the last year's customer.
Write an algorithm to find the credit score.​

Answers

Answered by nidaeamann
9

Explanation:

The algorithm will start by taking the input of the balances of N customers.

Now for each balance, check if the balance is less than zero (negative) or greater than zero (positive) balances.

Now we need to sum all the balances such that;

Net balance = Sum of negative balance + Sum of positive balance

Credit score = Net balance x smallest product price

Now if credit score is positive;

    Then credit it to current year's customer

Else

     Credit it to previous year's customer

Answered by elonmusktesla369
17

Answer:

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

int[] block = new int[n];

for(int i=0;i<n;i++)

{

block[i]= sc.nextInt();

}

int result = Payment(block);

System.out.print(result);

}

private static int Payment(int[] block) {

// TODO Auto-generated method stub

for (int i = 1; i < block.length; ++i) {

if (block[0] < block[i]) {

block[0] = block[i];

}

}

int greatest=block[0];

int min = block[0];

for (int i = 0; i < block.length; i++) {

if(block[i] <min)

min = block[i];

}

int minimum = min;

return greatest*minimum;

}

}\

Similar questions