/ Assignment / assignment_4.java
assignment_4.java
 1  /*Problem Stetement 
 2   * You have a basket containing apples (a) and mangoes (m), and you have some money (rs). Your goal is to balance
 3   the basket so that the number of apples is equal to the number of mangoes 
 4   * If apples are more than mangoes, buy (a-m) mangoes at $1 per mango. //rs - (a - m)
 5   * if mangoes are more than apples, sell (m-a) mangoes at $1 per mango //rs - (m - a)
 6   * If apples and mangoes are already equal (a == m) , your money remain unchanged.  //rs
 7   
 8   Determine the remaining money (rs) after balancing the basket. 
 9   */ 
10  
11  import java.util.Scanner;
12  
13  public class assignment_4 {
14    public static void main(String[] args) {
15      Scanner sc = new Scanner(System.in);
16  
17      System.out.println("Enter number of apples: ");
18      int a = sc.nextInt();
19  
20      System.out.println("Enter number of Mangoes: ");
21      int m = sc.nextInt();
22  
23      System.out.println("Enter the money in hand: "); 
24      int rs = sc.nextInt();
25  
26      if (a > m) {
27        System.out.println("Remaining Money");
28        System.out.println(rs - (a - m));      
29      }
30      else if (a < m) {
31        System.out.println("Remaining Money");
32        System.out.println(rs + (m - a));
33        
34      } else {
35        System.out.println("Remaining Money");
36        System.out.println(rs);      
37      }
38    }
39  }