Access over 35 million academic & study documents

Java Program

Content type
User Generated
Subject
Java
School
Brookhaven College
Type
Homework
Rating
Showing Page:
1/2
Java Program
import javax.swing.JOptionPane;
public class Test
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Enter a real number:");
double real1 = Double.parseDouble(input);
input = JOptionPane.showInputDialog("Enter another real number:");
double real2 = Double.parseDouble(input);
if (real1 >= 0)
{
if (real2 >= 0)
{
System.out.printf("The product of the numbers is %.2f", (real1 * real2));
JOptionPane.showMessageDialog(null, String.format("The product of the numbers is %.2f",
(real1 * real2)));
}
else
{
System.out.printf("INVALID INPUT");
JOptionPane.showMessageDialog(null, "INVALID INPUT");
}
}
else if (real1 < 0)
{
if (real2 < 0)
{
System.out.printf("The quotient of the numbers is %.2f", (real1 / real2));
JOptionPane.showMessageDialog(null, String.format("The quotient of the numbers is
%.2f", (real1 / real2)));
}
else
{
System.out.printf("INVALID INPUT");
JOptionPane.showMessageDialog(null, "INVALID INPUT");

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/2

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
Java Program import javax.swing.JOptionPane; public class Test { public static void main(String[] args) { String input = JOptionPane.showInputDialog("Enter a real number:"); double real1 = Double.parseDouble(input); input = JOptionPane.showInputDialog("Enter another real number:"); double real2 = Double.parseDouble(input); if (real1 >= 0) { if (real2 >= 0) { System.out.printf("The product of the numbers is %.2f", (real1 * real2)); JOptionPane.showMessageDialog(null, String.format("The product of the numbers is %.2f", (real1 * real2))); } else { System.out.printf("INVALID INPUT"); JOptionPane. ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Great study resource, helped me a lot.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4