Sunday
May 19, 2013

Homework Help: Java

Posted by Thanh on Tuesday, July 14, 2009 at 6:46pm.

I am supposed to convert a program i already made into a Java console application that uses the Scanner class to read the user's input. This is the code i have that i need to convert. I dont know where to start. Here is the code

import javax.swing.JOptionPane;
public class HW3 {





public static void main (String args[])
{

String firstNum;
String secondNum;
int num1;
int num2;
int sum;
int difference;
int quotient;
int product;


firstNum = JOptionPane.showInputDialog("Enter first integer: " );
secondNum = JOptionPane.showInputDialog("Enter second integer: " );
num1 = Integer.parseInt( firstNum );
num2 = Integer.parseInt( secondNum );
sum = num1 + num2;
difference = num1 - num2;
product = num1 * num2;
quotient = num1 / num2;


JOptionPane.showMessageDialog(null, "The sum is " + sum,
"Results", JOptionPane.PLAIN_MESSAGE );
JOptionPane.showMessageDialog(null, "The difference is " + difference);
JOptionPane.showMessageDialog(null, " The quotient is" + quotient);
JOptionPane.showMessageDialog(null, "The product is" + product);
System.exit( 0 );
}
}

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

Java help please - I am trying to run the following program and am getting this ...
java - Write a java application that finds the smallest of several integers. ...
programming - I am supposed to modify this program so it begins by asking the ...
java - can anyone help me with this? I'm new to java! Write a program that ...
programming - Having troube with java, i am not a regular programmer, if anybody...
Java - I am trying to write an algorithm for my JAVA class and am having some ...
Computer Science-Java - Hi, I am writing an application class for a Lunar ...
Computer Sciene-java - Write a loop that will continuously prompt the user for ...
Computer Science - Java - Hi, For an assignment I am doing, we have to have 2 ...
programming - write a program that maintains two parallel arrays. after th ...

For Further Reading

Search
Members
Community