私はこのプログラムをまとめましたが、最初のものでしたが、ボックスに値を入力すると、最後の出力は減算ではなく "0"になります。私は何が欠けているのか分からない。減算がJavaプログラムで機能していない
import java.util.Scanner;
import javax.swing.JOptionPane;
public class PSEUDOCODE_PROGRAM {
public static void main(String[] args) {
Scanner scnr= new Scanner(System.in);
String applesHad = " ";
String applesNeed = " ";
String orangesHad = " ";
String orangesNeed = " ";
int applesTheyHave = 0;
int applesTheyNeed = 0;
int orangesTheyHave = 0;
int orangesTheyNeed = 0;
int applesToOrder = 0;
int orangesToOrder = 0;
applesToOrder = applesTheyNeed - applesTheyHave;
orangesToOrder = orangesTheyNeed - orangesTheyHave;
//Ask produce buyer how many apples are in stock
applesHad= JOptionPane.showInputDialog(null, "How many apples do you have: ");
applesTheyHave = Integer.parseInt(applesHad);
applesHad= JOptionPane.showInputDialog(null, "How many apples do you need: ");
applesTheyNeed = Integer.parseInt(applesHad);
//Ask produce buyer how many oranges are in stock
orangesHad= JOptionPane.showInputDialog(null, "How many oranges do you have: ");
orangesTheyHave = Integer.parseInt(orangesHad);
orangesHad= JOptionPane.showInputDialog(null, "How many oranges do you need: ");
orangesTheyNeed = Integer.parseInt(orangesHad);
JOptionPane.showMessageDialog(null, "You must order " + applesToOrder + " apples and " + orangesToOrder + " oranges!");
を取った後、あなたは説明でき文を置きますか? – Tom
その質問をしなかったので、次回はそのことを覚えておきます。 tks –