Learn Programming through funny ways!  Here, we are going to solve Profit and Loss related Aptitude through our Logical Thinking series.

QUESTION

A, B, C subscribe Rs. 50,000 for a business. A subscribes Rs. 4000 more than B and B Rs. 5000 more than C. Out of a total profit of Rs. 35,000.  How much does A receive?

ANSWER:  14700

ALGORITHM

  1. Get the total profit value from user
  2. Initialize a=4000,b=5000,amt=50000
  3. Add the value of and b to get the a’s original amount
  4. Then add the a’s original amount and the b value and subtract it from amt and store it in cvalue
  5. Then divide the cvalue by 3
  6. Find the a&b value by adding cvalue with a’s original amount and b value
  7. Find the ratio of a,b,c by dividing the a,b,c value by 1000
  8. Now add the a,b,c ratios to get the total value
  9. Now find a’s share by multiplying profit value with a’s ratio and divide dy the total value

Profit Share Program in Java

package my.app2;

import java.util.Scanner;

public class App2 {

public static void main(String[] args) {

System.out.println(“enter the total profit”);

Scanner scanner = new Scanner(System.in);

int p = scanner.nextInt();

int a=4000,b=5000;

int a_modval=a+b, a_share, cvalue_by_ab;

int amt=50000, cValue,a_amount,b_amount,a_ratio,b_ratio,c_ratio,totalRatio;

int sumOffab+a_modval;

cValue_by_ab=amt-sumOfab;

cValue=cValue_by_ab/3;

a_amount=cValue+a_modval;

b_amount=cValue+b;

a_ratio=a_amount/1000;

b_ratio=b_amount/1000;

c_ratio=cValue/1000;

totalRatio=a_ratio+b_ratio+c_ratio;

// Calculating a’s share now. 

a_share=(p*a_ratio)/totalRatio;

System.out.print(“a’s share is: “+a_share);

}

}