私のプログラムの目的は、気温(F)とは何か、外の気象条件はどのようなものかを尋ねることです。
気象条件は、晴れ(1)、雨(2)、曇り(3)、雪(4)のいずれかになります。1〜4の数字は、気象条件を明確にするために使用されます(方法がわかりません)。それ以外の方法で...)
次に、との組み合わせに応じて、との組み合わせに基づいて、10の選択肢から3つの衣服を表示できるようにしたいと思いtemp
ます。weatherCondition
temp
weatherCondition
私はまだ学んでいるので、私の質問や問題が平凡に思える場合はお詫びします...
temp
ユーザーがとを入力した瞬間にweatherCondition
、2つの入力の組み合わせ(例:暑い晴れ、凍るような雪)に応じて応答が返されます。
代わりに、1つ以上のtxtファイルを作成し、それぞれにたとえばhotSunny.txtのような名前を付けたいと思います。これらのtxtファイルの中に、10種類の衣服をリストしました。最終的には、プログラムが適切なtxtファイルに一致するコンボを認識し、10個のうち3個をランダムに表示するようにします。
私がこれまでに持っているもの...
public static void main(String[] args)
{
double temperature;
int weatherCondition;
String input;
input = JOptionPane.showInputDialog("What is " +
"the current temperature?");
temperature = Double.parseDouble(input);
input = JOptionPane.showInputDialog("Sweet I now know the temperature! " +
"Now please take a look out the nearest window is it Sunny , Rainy ," +
" Cloudy or Snowy? " +
"(1 = Sunny) (2 = Raining) " +
"(3 = Cloudy) (4 = Snowing)");
weatherCondition = Integer.parseInt(input);
if (temperature <= 32){
if (weatherCondition == 4){
freezingSnowing();
} else if (weatherCondition == 3){
freezingCloudy();
} else if (weatherCondition == 2){
freezingRain();
} else {
freezingSunny();
}
}..........
else if ((temperature >= 33) && (temperature <= 50)) {
else if ((temperature >= 51) && (temperature <= 75)) {
else if ((temperature >= 76) && (temperature <= 140)) {
public static void freezingSnowing()
{
JOptionPane.showMessageDialog(null, "It's is snowing! I recommend that you dress very warm" +
"and wear a large coat that is preferably water proof.");
}