Java trainer in Nagpur

Java program to generate random numbers

Objectives:

  • Write a Java program to to generate random numbers and print the same
  • Write a program to generate random numbers
  • Write a program to generate random numbers in Java

Java Program:

[sourcecode lang="java"]

import java.util.Scanner;
import java.util.Random;

class GenerateRandomNumber
{
public static void main(String[] args)
{
int maxRange;

//create objects
Scanner SC = new Scanner(System.in);
Random rand = new Random();

System.out.print("Please enter maximum range: ");
maxRange=SC.nextInt();

for(int i=1; i<=10; i++)
{
System.out.println(rand.nextInt(maxRange));
}
}
}

[/sourcecode]

Output:

Please enter maximum range: 500
467
61
100
449
68
316
445
224
54
498

Find duplicate characters in string

Objectives:

  • Write a Java program to find duplicate characters in the string and print the duplicate characters
  • Write a program to find duplicate characters in String

Java Program:

[sourcecode lang="java"]
public class DuplicateCharacters {
    public static void main(String args[]) {

        String str = "NITIN";
        int count = 0;

        char input[] = str.toCharArray();
        System.out.println("Duplicate Characters are:");

        for (int i = 0; i &amp;lt; str.length(); i++) {
            for (int j = i + 1; j &amp;lt; str.length(); j++) {
                if (input[i] == input [j]) {
                    System.out.println(input[j]);
                    count++;
                    break;
                }
           }
        }
    }
}
[/sourcecode]

Output:

Duplicate Characters are: N I

Passing String in Switch Case in Java

Objectives:

  • How to use switch case in Java?
  • How to use switch case with string in Java?
  • How to pass string literals in switch case in Java?

 

Source Code:

[sourcecode lang=”java”]

public class SwitchWithStringExample

{
public static void main(String[] args)
{
String str = "two";
switch(str)
{
case "one":
System.out.println("one");
break;
case "two":
System.out.println("two");
break;
case "three":
System.out.println("three");
break;
default:
System.out.println("no match");
} // switch close
} // main close
} // class close

[/sourcecode]

 

Steps to run above Java code:

Consider that we have saved code at C drive (c:\>) and the file is saved as SwitchWithStringExample.java

  1. Compilation : c:\> javac SwitchWithStringExample.java
  2. Interpretation : c:\> java SwitchWithStringExample

 

Output:

two

 

We conduct Java Training and Workshop for Corporates and College Students, if interested, please write to us on kloudsancyber@gmail.com

 

Aatul Palandurkar
International Trainer, and Author, NetBeans Dream Team Member

https://www.facebook.com/aatulpalandurkar
https://www.instagram.com/aatulpalandurkar/

Oracle Java Certifications For You

Oracle Java Certifications For You

The Java programming language is among the most widely used software development platforms in the IT industry nowadays. It is extensively being used and appreciated by individuals as well as organizations to transform their innovative ideas into working software solutions.

 

The Java programming language is among the most widely used software development platforms in the IT industry nowadays. It is extensively being used and appreciated by individuals as well as organizations to transform their innovative ideas into working software solutions.

 

Oracle Corporation is constantly working in the area of Java platform development. They provide Java certifications as well. Each of these java certifications verifies a certain level of expertise and knowledge of the Java platform belonging to specific domains.

 

Adding the best Java certification to your resume will help you grab the attention of the employer. A Java certification can validate your knowledge and expertise in working with Java. Preparing for a Java Certification can help you enhance your Java programming skills.

 

Oracle Java Certifications

 

Before diving in detail into the various Java certification courses offered by the Oracle Corporation, let’s first skim through a summarized introduction. Oracle Java certifications are categorized as follows:

 

Entry Level

  • Oracle Certified Associate Java Programmer (OCAJP)

 

Professional Level

  • Oracle Certified Professional Java Programmer (OCPJP)
  • Oracle Certified Professional Java Application Developer (OCPJAD)

 

Master/Architect Level

  • Oracle Certified Master Java Enterprise Architect (OCMJEA)

 

 

The Oracle OCP Java SE 8 Programmer I certification will validate your strong Java programming skills. To earn this certification you will have to pass the 1Z0-808 exam. The 1Z0-808 exam objectives include topics such as Java basics, Java data types, array, loop contracts, methods and encapsulation and so on.

 

 

 

The Oracle OCP Java SE 8 Programmer II certification is a professional-level certification designed to validate the foundation skills of database administration. The OCP 1Z0-809 exam objectives include exceptions and assertions; generics and collections; Java Class Design, Java File I/O (NIO.2), Java I/O Fundamentals, Java Stream API, and localization.

 

 

 

Oracle OCP Java SE 11 Developer certification covers a wide range of available Java 11 programming concepts. To earn this certification you will have to clear the 1Z0-815 exam. The Oracle 1Z0-815 exam covers topics such as Encapsulation, creating and using methods; creating simple Java programs, describing and using objects and classes; handling exceptions, Java technology, reusing implementations through Inheritance, 

understanding modules, and more.

As we all know that Java is employed for developing a wide array of applications. This programming language is used in creating server-side applications to mobile applications. So, if you are thinking about starting your career in this field, then you must consider these certifications. We offer courses that will help you prepare for the certification exams.

 

Simple Interest Example in Java

Starting a series of some Java programs as many students were asking to share the programs. Here is the first program of the series.

Objectives:

  • Write a Program that calculates and prints the simple interest using the formula : Simple Interest = PTR/100
  • How to calculate Simple Interest in Java?
  • Write a program to calculate Simple Interest in Java.
  • Write a Java program that calculates and prints the simple interest using the formula : “SimpleInterest = PTR/100” and input values P, T, R should be accepted as command line.
  • How to use Command Line Arguments in Java?
  • How to pass values from command line in Java?
  • How to take input in Java from console?

 

This particular program can be written in various ways, we will try to write the solution program in different ways here and one can try to understand the difference between them.

Method 1 :

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample {

public static void main(String[] args) {

int p,t,r, result;

Scanner sc = new Scanner(System.in);

System.out.println(&quot;Enter the Value of P : &quot;);
p = sc.nextInt();

System.out.println(&quot;Enter the Value of T : &quot;);
t = sc.nextInt();

System.out.println(&quot;Enter the Value of R : &quot;);
r = sc.nextInt();

result = (p*t*r)/100;
System.out.println(&quot;Interest is : &quot; + result);
}
}
[/sourcecode]

This one is the simplest way to write the program to find simple interest in Java. Here we have simply created the object of Scanner class for taking input. Scanner class was introduced in Java 6. To use Scanner class we will have to import the class from java.util package.

Method 2:

Now we will write a Java program that calculates and prints the simple interest using the Scanner class again but with object oriented programming approach.

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample
{
double principalAmount = 0;
double interestRate = 0;
double term = 0;
double simpleInterest = 0;

public void calculateSimpleInterest()
{
Scanner input = new Scanner(System.in);

System.out.print(&quot;Enter the Principal amount : &quot;);
principalAmount = input.nextDouble();

System.out.print(&quot;Enter the Rate As a decimal : &quot;);
interestRate = input.nextDouble();

System.out.print(&quot;Enter the amount of time in years : &quot;);
term = input.nextDouble();

simpleInterest = (principalAmount * interestRate * term) / 100;
}

public void displaySimpleInterest()
{
System.out.println(&quot;The Simple Interest is : &quot; + simpleInterest);
}
}
[/sourcecode]

Mock Test Program for above code so that we can test the code. keep both the classes in same package and run the Mock Test Program or MockTestProgram.java

[sourcecode lang=”java”]
public class MockTestProgram{

public static void main(String[]args);
{
SimpleInterestExample simpleInt = new SimpleInterestExample();
simpleInt.calculateSimpleInterest();
simpleInt.displaySimpleInterest();
}
}
[/sourcecode]

Method 3:

Now we will write a Java program that calculates and prints the simple interest using the formula : “SimpleInterest = PTR/100” and input values P, T, R should be accepted as command line.

[sourcecode lang=”java”]
import java.util.Scanner;

public class SimpleInterestExample {

public static void main(String[] args) {
double p,t,r, result;

p = Double.parseDouble(args[0]);
t = Double.parseDouble(args[1]);
r = Double.parseDouble(args[2]);

Scanner sc = new Scanner(System.in);

System.out.println(&quot;Enter the Value of P : &quot;);
p = sc.nextDouble();

System.out.println(&quot;Enter the Value of T : &quot;);
t = sc.nextDouble();

System.out.println(&quot;Enter the Value of R : &quot;);
r = sc.nextDouble();

result = (p*t*r)/100;
System.out.println(&quot;Interest is : &quot; + result);
}
}
[/sourcecode]

 

I will be sharing more programs soon as many students were asking for programs which were carried out during Java training and were asked in assignments after Java training. By the time enjoy coding in Java and use NetBeans, it will ease your life.

Java User Group, Nagpur (INDIA)

What is Java User Group, Nagpur

 Java User Group Nagpur is a forum for collaboration and creative interaction for all interested in Java and new technologies revolving around Java.

 

JUG Nagpur
Abbreviation for Java User Group and Nagpur is the name of city where this group is located. This group provides opportunities for group meetings, one to one expert sessions and presentations.

 

Project Page
http://java.net/projects/jugnagpur/
Project page is a link to the Java.net web site. This is the entry through which we will be listing our group in Java User Groups Community.

 

Mailing List
http://groups.google.com/group/jugnagpur
The mailing list is the most important collaboration tool we use. All the transactions and knowledge sharing happens through this mailing list.

 

Wiki
http://jugnagpur.wikispaces.com/
Group wiki make the space available to all the group members to contribute creatively. The content getting matured on the wiki will be selectively shifted to the web site.

 

Group Blog
http://jugnagpur.blogspot.com
Blog where all group members can write their experiences and news about the JUG events.

JUG Meetup : March 27, 2011

 

JUG Meetup : March 27, 2011

Time : 2pm – 4pm

Venue :

Atul Palandurkar,

125, “SHARDA”,

Parvati Nagar,

Rameshwari Road,

Nagpur – 440027.

Tushar Joshi, Atul Palandurkar, Shwetal Bahadure, Harshal Potliya, Rahul Raja

Attendees of JUG Meetup on 27-03-2011

Attendees :

(From Left to Right)

  1. Tushar Joshi
  2. Atul Palandurkar
  3. Shwetal Bahadure
  4. Harshal Potliya
  5. Rahul Raja

 

Today’s meeting was very important for all of us, mainly Shwetal Bahadure & Harshal Potliya who are about to join the group very soon.

 

Sir & we discussed about various important thing & tasks to be done via JUG Nagpur likewise what is open source project? How to create a open source projects & finish it? Ways to spread the JUG Nagpur to more people of Nagpur, and how to make world know about JUG Nagpur? Even we discussed our view about being a member of the group, opportunities we may found while being in JUG Nagpur, exchange of ideas & the things we can learn from each other while being together in this group.

 

We planned to have 17 & possibly more different YANPAs (Yet Another NetBeans Platform Application) in accordance with the NetBeans User Group, Nagpur. Here we are not planning for something great but just to make it for the first time & later on will come back with something really exciting & useful for everyone!

 

We also planned to spread the JUG Nagpur to each & every professional & student of Nagpur who is interested in Java & its technologies.

 

Here at the meeting we also discussed about managing the website & wiki of JUG Nagpur, and to manage the FAQ pages & other pages & then to change the role after sometime so that everyone can learn how to do the particular task?