Home

JAVA

CLASS ROOM

 

JAVA Class Room

cookieless tracking

Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented, and specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that compiled contests Java code can run on all platforms that support Java without the need for recompilation. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture. As of 2015, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers. Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them. Java can be hard to deal with for some students, so sometimes they turn to assignmentholic.co.uk homework help service for assistance.

The Upside to Contests

Many of the ideas above are contests and naturally, contests should have prizes.  These contests provide cash and other type of prizes to the winners.  Numerous contests may also be incorporated into your celebration.

The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licences. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License. Others have also developed alternative implementations of these Sun technologies, such as the GNU Compiler for Java (bytecode compiler), GNU Classpath (standard libraries), and IcedTea-Web (browser plugin for applets).

 

import java.util.Random;

public class Array {

public static int average(int[] array)

{

int avg=0,sum=0,num=0;

for(int i=0;i<array.length;i++)

{

sum=sum+array[i];

System.out.println(array[i]);

num++;

}

avg=sum/num;

return avg;

}

public static double average(double[] array)

{

int num=0;

double avg=0,sum=0;

for(int i=0;i<array.length;i++)

{

sum=sum+array[i];

String str = String.format("%.02f", array[i]);

System.out.println(str);

num++;

}

avg=sum/num;

return avg;

}

public static void main(String[] args)

{

Random r=new Random();

int[] array=new int[10];

double[] a=new double[10];

for(int i=0;i<array.length;i++)

{

array[i]=r.nextInt(100);

}

for(int i=0;i<a.length;i++)

{

a[i]=r.nextDouble()*51.0;

}

Array arr=new Array();

int avg1=arr.average(array);

System.out.println("Average is: "+avg1);

double avg2=arr.average(a);

String str = String.format("%.02f", avg2);

System.out.println("Average is: "+str);

}

}

package JavaClassRoom.com;

import java.util.Scanner;

public class WorkerSalary {

public static void main(String[] args)

{

int no_of_Workers;

double salary=0,x,total=0,below=0;

Scanner in=new Scanner(System.in);

System.out.println("Please enter nuber of workers?");

no_of_Workers=in.nextInt();

double[] hours=new double[no_of_Workers];

System.out.println("Please enter the salary below 8 hours:");

below=in.nextDouble();

for(int i=0;i<no_of_Workers;i++)

{

System.out.println("Please enter Wroker "+(i+1)+"'s Working hours:");

hours[i]=in.nextDouble();

if(hours[i]<=8)

{

salary=hours[i]*below;

}

else if(hours[i]>8)

{

x=hours[i]-8;

salary=(x*9.0)+(hours[i]-x)*below;

}

total +=salary;

System.out.println("Worker "+(i+1)+"'s salary is:"+salary);

}

System.out.println("The total salary for the "+no_of_Workers+"workers is:"+total);

}

}

 

package JavaClassRoom.com;

 

public class ClosePoints

{

public static void main(String[] args)

{

double[][] points = {{-1, 2, 3}, {-1, -1, -1}, {5, 2, 1}, {3, 0.5, 9},

{3.5, 2, -1.5}, {8, 1.5, - 3}, {-4, 4, 2}, {-7, 4, -0.5}};

double shortestDistance=0;

double distance=0;

String closestPoint1="";

String closestPoint2="";

 

//get the distance between the point in the ith row and the (m+1)th row

//and check if it's shorter than the distance between 0th and 1st

for (int i=0; i<points.length; i++)

{

//use m=i rather than 0 to avoid duplicate computations

for (int m=i; m<points.length-1;m++)

{

double dx = points[i][0] - points[m+1][0];

double dy = points[i][1] - points[m+1][1];

double dz = points[i][2] - points[m+1][2];

distance = Math.sqrt(dx*dx + dy*dy + dz*dz);

 

//set shortestDistance and closestPoints to the first iteration

if (m == 0 && i == 0)

{

shortestDistance = distance;

closestPoint1 = "(" + points[0][0] + "," + points[0][1] + ","+ points[0][2] + ")";

closestPoint2 = "(" + points[1][0] + "," + points[1][1] + ","+ points[1][2] + ")";

}

//then check if any further iterations have shorter distances

else if (distance < shortestDistance)

{

shortestDistance = distance;

closestPoint1 = "(" + points[i][0] + "," + points[i][1] + ","+ points[i][2] + ")";

closestPoint2 = "(" + points[m+1][0] + "," + points[m+1][1] + ","+ points[m+1][2] + ")";

}

}

}

System.out.println("The shortest distance is: " + shortestDistance);

System.out.println("The closest points are " + closestPoint1 + " and " + closestPoint2);

}

}

Post your java Queries below.. I will try to post answer...