이 곳을 처음 방문했지만 저는 StackOverflow에서 찾은 모든 것을 좋아했습니다. 지금 나는 자바 클래스에서 최종 프로젝트를 위해 만든 오래된 프로그램을 빌드하려고 노력하고 있지만, 슬프게도 나는로드 덤프를 쳤다.입력이있는 JFrame 삽입 및 출력 표시
내 프로그램이 사용자의 온도를 요청한 다음 화씨 또는 섭씨인지 묻습니다. 그런 다음 화씨와 섭씨 모두를 계산하고 뜨겁거나 추운 날씨, 가벼운 날씨 등의 여부를 사용자에게 알려줍니다.
내가 지금하고 싶은 것은 달리고 실행할 수있게하는 것입니다. 이것은 Visual Basic과 같은 팝업 창에 표시됩니다. 가능한가?
package temperaturereader;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.util.Scanner;
/**
*
* @author pcstudent
*/
public class TemperatureReader {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//Declare your Variables
double input = 0.0;
double Fahrenheit= 0.0;
double Celsius= 0.0;
String ForC;
String Hot = "It is hot today.";
String Cold = "It is cold today.";
String Cool = "It is cool today.";
String Warm = "It is warm today.";
String Freezing = "It is freezing today. Take a jacket.";
String TooHot = "It is dangerously hot. Stay hydrated.";
String SunHot = "You are currently standing on the sun.";
String Oymyakon = "You are in Oymyakon, Russia.";
//Asking for Temperature
Scanner one = new Scanner(System.in);
System.out.println("Enter the temperature:");
input = one.nextDouble();
//Asking for Fahrenheit or Celsius
Scanner two = new Scanner(System.in);
System.out.println("Is the temperature in Fahrenheit or Celsius?");
ForC = two.next();
//Check for Fahrenheit and convert accordingly
if (ForC.equalsIgnoreCase("Fahrenheit")) {
Fahrenheit = input;
Celsius = (Fahrenheit -32)*.5556;
}
else if (ForC.equalsIgnoreCase("F")) {
Fahrenheit = input;
Celsius = (Fahrenheit -32)*.5556;
}
//Check for Celsius and convert accordingly
else if (ForC.equalsIgnoreCase("Celsius")) {
Celsius = input;
Fahrenheit = (Celsius*1.8) + 32;
}
else if (ForC.equalsIgnoreCase("C")){
Celsius = input;
Fahrenheit = (Celsius*1.8) + 32;
}
//If there is an error, stop the program.
else {
System.out.println("Error.");
System.exit(0);
}
System.out.println("");
//Compare temperatures and display.
if (Fahrenheit >= 9941) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(SunHot);
}
else if (Fahrenheit >= 105) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(TooHot);
}
else if (Fahrenheit >= 80) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celcius.");
System.out.println("");
System.out.println(Hot);
}
else if (Fahrenheit >= 60) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(Warm);
}
else if (Fahrenheit >= 59) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(Cool);
}
else if (Fahrenheit >= 40) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(Cold);
}
else if (Fahrenheit >= 32) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(Freezing);
}
else if (Fahrenheit >= -58) {
System.out.println("The temperature is currently " + Fahrenheit + " degrees Fahrenheit and " + Celsius + " degrees Celsius.");
System.out.println("");
System.out.println(Oymyakon);
}
else {
System.out.println("");
}
}
는 당신이 얻을 문제입니다 ? – Yahya
가능합니까? 예. 웹에서 사용할 수있는 모든 종류의 자습서가 있습니다. StackOverflow는 "이봐, 나에게 이걸하는 법을 말해줘"가 아니라, 네가 뭘 시도했는지 보여주고 네가 갇혀있는 곳을 설명하기위한거야. 자세한 지침은 http://stackoverflow.com/help/how-to-ask를 참조하십시오. – betseyb
시작하려면 SO는 튜토리얼 사이트가 아니므로 시작하기 위해 스스로 노력해야합니다. [JFC/Swing으로 GUI 생성하기] (http://docs.oracle.com/javase/tutorial/uiswing/) 및 [프레임 작성 방법 (메인 윈도우)] (https://docs.oracle) .com/javase/tutorial/uiswing/components/frame.html). [JavaFX 시작하기] (http://docs.oracle.com/javafx/2/get_started/jfxpub-get_started.htm)도보실 수 있습니다. – MadProgrammer