import javax.swing.*;import java.text.*;class AllFives { public static void main (String [] args) { double a; double cg; a = JOptionPane.showInputDialog(null, "Please enter the value of A"); cg = (Math.pow(a, 0.5e1) + 0.5e1) / a / 0.5e1; JOptionPane.showMessageDialog(null, "A = " + cg);}}
9/13/2005 10:06:38 AM
showInputDialog returns a string, not a double...
9/13/2005 10:12:12 AM
forgot to parse
9/13/2005 10:14:41 AM
another question:
/* Converts seconds into minutes, hours, days */import javax.swing.*;import java.text.*;public class SecondsConvert { public static void main (String [] args) { String secondsStr; int seconds, minutes, hours; System.out.println( "This program converts a total number of seconds "); System.out.println( "into the equivalent minutes and seconds. "); secondsStr = JOptionPane.showInputDialog(null, "Enter the seconds: "); seconds = Integer.parseInt(secondsStr); minutes = seconds / 60; seconds = seconds % 60; System.out.println(); System.out.println(seconds + " seconds = " ); System.out.println( minutes + " minutes, and " + seconds + " seconds. "); }}// 1. For which range of input values does the existing program work as expected?
9/13/2005 11:06:30 AM
so whats the question? the one in comments?sounds like a homework question to me...
9/13/2005 11:10:51 AM
Well it's a lab and the teacher isn't here, so I have no way of contacting him and we don't have a TA.anywayYeah ignore that comment. The question is how can I correct incorrect ranges, which im assuming a incorrect range is a decimal # because the program errors up. I tried using the DecimalFormat to ("0") but that only likes doubles. I don't need an answer, just a direction to be looking in and i'll figure it out.
9/13/2005 11:14:45 AM
well, I think the only hint I can give you is to look at the variable type... is a number with a decimal an integer?[Edited on September 13, 2005 at 11:25 AM. Reason : nevermind that last piece...]
9/13/2005 11:23:41 AM