Methods for Scanner Objects
NASA
𓃗
todays bird
occasionally subtle

oozey mess
PUT YOUR BEARD IN MY MOUTH

Discoholic 🪩
Keni
untitled
Stranger Things
d e v o n
Misplaced Lens Cap

blake kathryn

No title available
we're not kids anymore.

Product Placement
Show & Tell
trying on a metaphor

gracie abrams
Noah Kahan

seen from Türkiye
seen from Norway
seen from United States
seen from United States
seen from United Kingdom

seen from United States
seen from United States
seen from Canada

seen from United States

seen from Singapore

seen from United States
seen from United Kingdom
seen from Canada

seen from Singapore
seen from United States
seen from United States

seen from United States

seen from Malaysia

seen from United States

seen from United States
@computerprogrammingstuff
Methods for Scanner Objects
The result when the previous program is executed.
2.2 Reading Input from the Console
import java.util.Scanner; // Scanner is in the java.util package
public class ComputeAreaWithConsoleInput
{
public static void main(String[] args)
{
// Create a Scanner object
Scanner input = new Scanner(System.in);
// Prompt the user to enter a radius
System.out.print("Enter a number for radius: ");
double radius = input.nextDouble();
// Compute area
double area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
}
This is the result of the previous program being executed.
ComputeArea.java
public class ComputeArea
{
public static void main(String[] args)
{
double radius; // Declares radius
double area; // Declares area
radius = 20;
area = radius * radius * 3.14159;
// Display results
System.out.println("The area for the circle of radius " +
radius + " is " + area);
}
}
This is the result of the program being executed from the previous post.
WelcomeInMessageDialogBoxAlt.java
/*This application program displays Welcome to Java!
*in a message dialog box.
*/
import javax.swing.JOptionPane;
public class WelcomeInMessageDialogBoxAlt
{
public static void main(String[] args)
{
// Diplays Welcome to Java! in a message dialog box
JOptionPane.showMessageDialog(null,
"Welcome to Java!",
"Display Message",
JOptionPane.INFORMATION_MESSAGE);
}
}
This is the result when the program in the previous post is executed.
WelcomeInMessageDialogBox.java 1.4
/*This application program displays Welcome to Java!
*in a message dialog box.
*/
import javax.swing.JOptionPane;
public class WelcomeInMessageDialogBox
{
public static void main(String[] args)
{
// Diplays Welcome to Java! in a message dialog box
JOptionPane.showMessageDialog(null, "Welcome to Java!");
}
}
Computing an Expression in Java 1.3
public class ComputeExpression
{
public static void main(String[] args)
{
System.out.println((10.5 + 2 * 3) / (45 - 3.5));
}
}
// This is the answer you get: 0.39759036144578314
First Java Program 1.1
public class Welcome
{
public static void main(String[] args)
{
// Display message Welcome to Java! on the console
System.out.println("Welcome to Java!");
}
}