学校の課題なので、このコードは無意味です。char を使用しようとするたびに、常にこのエラーが発生するようです
LetsGoShop.java:14: error: cannot find symbol
item = input.nextChar();
^
symbol: method nextChar()
location: variable input of type Scanner
1 error
Heres 実際のコード:
import java.util.Scanner;
public class LetsGoShop {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
char item ;
int price;
int quantity;
System.out.println(" Enter the name of the item : ");
item = input.nextChar();
System.out.println(" Enter the price of said item : ");
price = input.nextInt();
System.out.println(" Enter how much of said item you want to buy : ");
quantity = input.nextInt();
double total = price * quantity ;
item = Character.toUpperCase(item);
System.out.println(" You owe " +total+ " for " +quantity + item);
}
}
私はコーディングを始めたばかりなので、答えが明らかであれば、私はそれを推測していなかったでしょう.