i try JOPtion but it got different error
This post has been edited by macosxnerd101: 19 August 2010 - 10:27 AM
Reason for edit:: Title renamed to be more descriptive. Please respect rule #4 of this forum.




Posted 19 August 2010 - 07:24 AM
This post has been edited by macosxnerd101: 19 August 2010 - 10:27 AM
Reason for edit:: Title renamed to be more descriptive. Please respect rule #4 of this forum.
Posted 19 August 2010 - 07:25 AM
Posted 19 August 2010 - 07:42 AM
import javax.swing.JOptionPane;
public class NumberOfMonth2
{
public static void main(String[]args)
{
int Year, Month;
String introduction = "This program tell about the day of month base of the year that entered by the user.\n";
JOptionPane.showMessageDialog( null, introduction );
Year =Integer.parseInt(JOptionPane.showInputDialog("Input A Year:"));
Month =Integer.parseInt(JOptionPane.showInputDialog("Input Month"));
if (Year%4>0){ //NOT LEAP YEAR
if (Month==1){
JOptionPane.showMessageDialog(null, "That month is a January!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==2){
JOptionPane.showMessageDialog(null, "That month is a Febuary!");
JOptionPane.showMessageDialog(null, "There's 28 days on that month");}
if (Month==3){
JOptionPane.showMessageDialog(null, "That month is a March!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==4){
JOptionPane.showMessageDialog(null, "That month is a April!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==5){
JOptionPane.showMessageDialog(null, "That month is a May!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==6){
JOptionPane.showMessageDialog(null, "That month is a June!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==7){
JOptionPane.showMessageDialog(null, "That month is a July!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==8){
JOptionPane.showMessageDialog(null, "That month is a August!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==9){
JOptionPane.showMessageDialog(null, "That month is a September!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==10){
JOptionPane.showMessageDialog(null, "That month is a October!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==11){
JOptionPane.showMessageDialog(null, "That month is a November!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==12){
JOptionPane.showMessageDialog(null, "That month is a December!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
}
if (Year%4==0){ //LEAP YEAR
if (Month==1){
JOptionPane.showMessageDialog(null, "That month is a January!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==2){
JOptionPane.showMessageDialog(null, "That month is a Febuary!");
JOptionPane.showMessageDialog(null, "There's 29 days on that month");}
if (Month==3){
JOptionPane.showMessageDialog(null, "That month is a March!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==4){
JOptionPane.showMessageDialog(null, "That month is a April!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==5){
JOptionPane.showMessageDialog(null, "That month is a May!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==6){
JOptionPane.showMessageDialog(null, "That month is a June!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==7){
JOptionPane.showMessageDialog(null, "That month is a July!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==8){
JOptionPane.showMessageDialog(null, "That month is a August!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==9){
JOptionPane.showMessageDialog(null, "That month is a September!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==10){
JOptionPane.showMessageDialog(null, "That month is a October!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
if (Month==11){
JOptionPane.showMessageDialog(null, "That month is a November!");
JOptionPane.showMessageDialog(null, "There's 30 days on that month");}
if (Month==12){
JOptionPane.showMessageDialog(null, "That month is a December!");
JOptionPane.showMessageDialog(null, "There's 31 days on that month");}
}
} // end main
} // end class
macosxnerd101, on 19 August 2010 - 06:25 AM, said:
This post has been edited by macosxnerd101: 19 August 2010 - 10:26 AM
Reason for edit:: Added code tags. Please use them in the future.
Posted 19 August 2010 - 08:51 AM
import java.util.*;
public class MaxMinAvg {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double maxnumber = Double.MIN_VALUE;
double minNumber = Double.MAX_VALUE;
int count = 0;
double totalNumber = 0;
System.out.println("Enter five number. Write DONE if u are entered 5 DIGIT");
while (input.hasNextDouble()) {
double number = input.nextDouble();
if (number > maxnumber) {
maxnumber = number;
}
if (number < minNumber) {
minNumber = number;
}
count++;
totalNumber += number;
}
if (count > 0) {
//... Display statistics
double average = totalNumber / count;
System.out.println("Number of values = " + count);
System.out.println("Maximum = " + maxnumber);
System.out.println("Minimum = " + minNumber);
System.out.println("Average = " + average);
} else {
System.out.println("Error: You entered no data!");
}
}
}
This post has been edited by macosxnerd101: 19 August 2010 - 10:24 AM
Reason for edit:: Added code tags. Please use them in the future.
Posted 19 August 2010 - 09:43 AM
import java.util.*;
public class MaxMinAvg {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double maxnumber = Double.MIN_VALUE;
double minNumber = Double.MAX_VALUE;
int count = 0;
double totalNumber = 0;
System.out.println("Enter five number. Write DONE if u are entered 5 DIGIT");
while (input.hasNextDouble()) {
double number = input.nextDouble();
if (number > maxnumber) {
maxnumber = number;
}
if (number < minNumber) {
minNumber = number;
}
count++;
totalNumber += number;
}
if (count > 0) {
//... Display statistics
double average = totalNumber / count;
System.out.println("Number of values = " + count);
System.out.println("Maximum = " + maxnumber);
System.out.println("Minimum = " + minNumber);
System.out.println("Average = " + average);
} else {
System.out.println("Error: You entered no data!");
}
}
}
Luckless, on 19 August 2010 - 08:05 AM, said:
import java.util.*;
public class MaxMinAvg {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double maxnumber = Double.MIN_VALUE;
double minNumber = Double.MAX_VALUE;
int count = 0;
double totalNumber = 0;
System.out.println("Enter five number. Write DONE if u are entered 5 DIGIT");
while (input.hasNextDouble()) {
double number = input.nextDouble();
if (number > maxnumber) {
maxnumber = number;
}
if (number < minNumber) {
minNumber = number;
}
count++;
totalNumber += number;
}
if (count > 0) {
//... Display statistics
double average = totalNumber / count;
System.out.println("Number of values = " + count);
System.out.println("Maximum = " + maxnumber);
System.out.println("Minimum = " + minNumber);
System.out.println("Average = " + average);
} else {
System.out.println("Error: You entered no data!");
}
}
}
Posted 19 August 2010 - 09:47 AM
import javax.swing.JOptionPane;
import java.util.*;
public class RJ2 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double maxnumber = Double.MIN_VALUE;
double minNumber = Double.MAX_VALUE;
int count = 0;
double totalNumber = 0;
String introduction = "Enter five number. Write DONE if u are entered 5 DIGIT.\n";
String outputMessage;
JOptionPane.showMessageDialog( null, introduction );
while (input.hasNextDouble()){
double number = input.nextDouble(); // <---- dis part i don't know how it will make JOptiondialog
if (number > maxnumber) {
maxnumber = number;
}
if (number < minNumber) {
minNumber = number;
}
count++;
totalNumber += number;
}
double average = totalNumber / count;
outputMessage = "Number of values = " + count + "\n\n"
+ "Maximum = " + maxnumber + "\n\n"
+ "Minimum = " + minNumber + "\n\n"
+ "Average = " + average + "\n\n"
+ "End of program";
JOptionPane.showMessageDialog( null, outputMessage );
System.exit(0);
}
}
Posted 19 August 2010 - 10:08 AM
This post has been edited by H3R3T1C: 19 August 2010 - 10:09 AM
Posted 19 August 2010 - 10:09 AM
JOptionPane.showInputDialog
Posted 19 August 2010 - 10:28 AM
|
|
Query failed: connection to localhost:3312 failed (errno=111, msg=Connection refused).
|
