Java | JSP | JSF Answers

Questions answered by Experts: 3 611

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

real life example of package and file handling in java???
hi,my name is dayo.i am new to java programming i am bout to write my first program which i copied from a textbook i am reading.

// A program to display the message
// "Hello World!" on standard output

public class HelloWorld {

public static void main(String[] args) {
System.out.println("Hello World!");
}

} // end of class HelloWorld

but the compiler is giving an error system.out.print class.the compiler made a suggestion 1 should be a package class before it can be used by the compiler.pls i do i go about it.thank you.
Provide two alternatives (1 for loop and 1 while loop) to the loop in fig. 5.12 that does not change the programs output but also does not use a "break" statement. Modify the sample code below to have a single return statement. Prepare all three modifications in a Word document with a discussion as to why using break in this way as well as using multiple return statements is not considered good programming form by most in the field.

Sample Code:

public boolean isTheFirstOneBigger(int num1, int num2)
{
if (num1 > num2)
{
return true;
}

if (num1 <= num2)
{
return false;
}
}
Hi,
I'm new to java programming and i need the explanation why we use
public static void main(String args[])
and why we use "main" only rather than other word...please help me....
Below is the start of my program but i need to have the filename of yournamehw1.java.

import java.util.Scanner;

public class Divide {

public static void main (String args [] ) {

make kybd = new Scanner (System.in);

System.out.print("Enter number 1: ");
I want to output 0,1,1,2,3,5,8,13,21,34
I just need an example java program with at least 3 data fields, 2 constructors and 4 methods
How to write/start a class with 2 objects?
public static void main(String[] args)
{
Scanner console = new Scanner(System.in);
System.out.print("Enter the value of a: ");
int a = console.nextInt();
System.out.print("Enter the value of b: ");
int b = console.nextInt();
System.out.print("Enter the value of h: ");
int h = console.nextInt();
double area = (a + b) * h / 2;
System.out.println("Area = " + "(" + a + " + " + b + ")" + " * " + h + " / " + 2 );
System.out.println("Area = " + area);
if ( a > 0 || b > 0 || h > 0)
break;
int count = 0;
for (; n = area; n++)
{
count++;
}
System.out.println("The number of trapezium calculated: " + count);
System.out.println("End.");
}
How do I use scanner for this code and calculate & print the area of the trapezium as many time until the user key in a non-positive input.
import java.util.Scanner;

public class NetbeanTest{
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.print("Enter Operator (+,-,*,/): ");
String plan = console.nextLine();
System.out.print("Enter Value 1: ");
int num1 = console.nextInt();
System.out.print("Enter Value 2: ");
int num2 = console.nextInt();
int result;

if (plan.equals(" + ")) result = num1 + num2; {
System.out.println("Result of " + num1 + " + " + num2 + " = " + result);}
if (plan.equals(" - ")) result = num1 - num2; {
System.out.println("Result of " + num1 + " - " + num2 + " = " + result);}
if (plan.equals(" * ")) result = num1 * num2; {
System.out.println("Result of " + num1 + " * " + num2 + " = " + result); }
if (plan.equals(" / ")) result = num1 / num2; {
System.out.println("Result of " + num1 + " / " + num2 + " = " + result);}
}}
// What went wrong?//
LATEST TUTORIALS
APPROVED BY CLIENTS