Tuesday, 25 August 2020

JAVA PROGRAMMING FOR CALCULATING SIMPLE INTEREST (USER INPUT)

 SIMPLE INTEREST

CALCULATION IN JAVA



  • ELEMENTS OF JAVA USED IN PROGRAMMING-: 

  1. int----->It is a data type that helps the user to assign a numerical value to a specific variable in a particular program.                                                             
  2. float---> It is a data type that helps the user to assign a decimal value to a specific variable in a particular program.                                                                NOTE-: Here you can also use "double" in place of "float" as this can store larger value than float.                                                                                           
  3. import--->It is the command that is used to import a particular set of files (pre installed in java ) to help the user to access different features of java.                 
  4. System.out.println()---> This command helps the user to print a particular value or displays a particular enclosed statement.                                            
  5. [ ; ]-----> This particular (symbol enclosed in square brackets ) i.e semicolon in java represents that a particular statement written by you is complete. 

  • NOTE-:

  1. CASE of letters must not be ignored.
  2. This program is a user input program. 
  3. After end of every statement  remember to close it with semicolon sign i.e ;
  4. none of the special characters  should be ignored. 

  • PROGRAMMING -:

package learning;

import java.util.Scanner ;



public class SimpleIntrest {


public static void main(String[] args) {

Scanner sc = new Scanner(System.in) ;

 

int principal = sc.nextInt();

float interestRate = sc.nextFloat();

float time = sc.nextFloat();

 

float interest = principal*interestRate*time/100 ;

 

System.out.println(interest);

 

sc.close();

 


}


}


NOTE-: The set-up that we import here is Scanner file and the name of the set-up file is "java.util.Scanner "it is a type of set-up file that helps user to input data .



  • PROGRAMMING IMAGE -:


  • INPUT AND OUTPUT IMAGE IN CONSOLE-:

     Output-1

 


   Output-2



NOTE-:  As you enter the first number in the console press the "Enter key", by doing this the computer automatically assigns the entered value to the first variable that you specified in the above programming . Now when you enter the second number and do the same, it is assigned the second variable.

If you need simpler example of this type of input programming then click on this link 

                                      

THANK YOU😌

FOR VISITING

PLEASE DO FOLLOW OUR PAGE 👦












No comments:

Post a Comment

Popular