Monday, September 26, 2016

Write a program that displays two numbers and uses the / and % operators to display the result and remainder after they are divided. Use the \t character escape code to separate the result and remainder in your output(Java OOP).

Phase 1(Method Body) :
1:  /*  
2:   * To change this license header, choose License Headers in Project Properties.  
3:   * To change this template file, choose Tools | Templates  
4:   * and open the template in the editor.  
5:   */  
6:  package mobileapplicationlicthomepractice.CoreJavaDay1Assignment;  
7:  /**  
8:   *  
9:   * @author Md.Asiful  
10:   * @serial 1.6.1  
11:   * @since 2016 September 24  
12:   * @author asm-linksys.com  
13:   */  
14:  public class TaskSixMethod   
15:  {  
16:    /**  
17:     *   
18:     * @param upValue   
19:     * @param downValue  
20:     * @return result=upValue/downValue  
21:     */  
22:    public int dividerCalc(int upValue, int downValue)  
23:    {  
24:      int result=upValue/downValue;  
25:      return result;  
26:    }  
27:    /**  
28:     *   
29:     * @param upValue  
30:     * @param downValue  
31:     * @return result=upValue%downValue;  
32:     */  
33:    public int reminderCalc(int upValue, int downValue)  
34:    {  
35:      int result=upValue%downValue;  
36:      return result;  
37:    }  
38:  }  
Phase 2(Main Class):

1:  /*  
2:   * To change this license header, choose License Headers in Project Properties.  
3:   * To change this template file, choose Tools | Templates  
4:   * and open the template in the editor.  
5:   */  
6:  package mobileapplicationlicthomepractice.CoreJavaDay1Assignment;  
7:  import java.util.Scanner;  
8:  /**  
9:   *  
10:   * @author Md.Asiful  
11:   * @serial 1.6.2  
12:   * @since 2016 September 24  
13:   * @author asm-linksys.com  
14:   */  
15:  public class TaskSixMainClass {  
16:    /**  
17:     * @param args the command line arguments  
18:     */  
19:    public static void main(String[] args) {  
20:      /**  
21:       * @param scn use to take input from user  
22:       */  
23:      Scanner scn=new Scanner(System.in);  
24:      /**  
25:       * Promoting for Upper divisible value  
26:       * @param firstNumber for upperValue  
27:       */  
28:      System.out.println("Please Enter Upper Value = ");  
29:      int firstNumber=scn.nextInt();  
30:      /**  
31:       * Promoting for Lower divisible value  
32:       * @param secondNumber for secondNumber  
33:       */  
34:      System.out.println("Please Enter Lower Value = ");  
35:      int secondNumber=scn.nextInt();  
36:      /**  
37:       * New Instance of TaskFiveMethod   
38:       * @param taskSixMethod for new TaskSixMethod instance  
39:       */  
40:      TaskSixMethod taskSixMethod=new TaskSixMethod();  
41:      //Printing for test   
42:      //System.out.println(t6.dividerCalc(firstNumber, secondNumber));  
43:      /**  
44:       * @param tempDevideResult collect result from deviderCalc method.  
45:       */  
46:      int tempDivideResult=taskSixMethod.dividerCalc(firstNumber, secondNumber);  
47:      //Printing for test  
48:      //System.out.println(t6.reminderCalc(firstNumber, secondNumber));  
49:      /**  
50:       * @param tempReminderResult collect result from reminderCalc method  
51:       */  
52:      int tempReminderResult=taskSixMethod.reminderCalc(firstNumber, secondNumber);  
53:      System.out.println("Devided Value "+"\tReminder Value");  
54:      System.out.println(tempDivideResult+"\t"+"\t"+tempReminderResult);  
55:    }  
56:  }  
OUTPUT :

Github Link : Md. Asiful Haque Github








No comments: