Hello Daniweb,
So, I am currently working on a simple download time estimator program using JOptionPane and some loops.
I have some beginning code and wanted to check how it is working, only it seems I messed up something and am stuck in my loop when I run it. I will keep working at what I am missing. Here is my code...
package downloadTimeApp;
/*
* This program allows user input to find approximate download time.
* by my name
* date: 9/14/14
*/
import javax.swing.JOptionPane;
public class DownloadTimeApp {
public static void main(String[] args)
{
// display operational messages
String mBStr = JOptionPane.showInputDialog(null,
"Please enter file size (MB): ",
"Welcome to the Download Time Estimator",
3);
int mB = Integer.parseInt(mBStr);
int mbSpeed = 0;
int hours = 0;
int min = 0;
int sec = 0;
// get a number from the user
while (mB != 0)
{
if (mB >= 1)
{
mB = mB + 0;
}
else if (mB <= 0)
JOptionPane.showMessageDialog(null, "Invalid entry, not counted.", "Input Error", 2);
}
while (mbSpeed != 0)
{
if (mbSpeed >= 1)
{
mbSpeed = mbSpeed + 0;
}
else if (mbSpeed <= 0)
JOptionPane.showMessageDialog(null, "Invalid entry, not counted.", "Input Error", 2);
}
while (hours != 0)
{
if (hours <= 0)
{
hours = 0;
hours = 3600 / mB;
}
else if (hours >= 1)
{
hours = hours + 0;
}
}
// display the results
String message = "\n" +
"This download will take approximately" +
hours + "hours" +
min + "minutes" +
sec + "seconds";
JOptionPane.showMessageDialog(null, message, "Show solution", 1);
}
}