I have this code in Java,
package bookpurchased;
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Book {
public static void getInputFromScanner() {
Scanner input = new Scanner(System.in);
System.out.print("Enter the Number you want: ");
Short bookId = input.nextShort();
System.out.println("\nBook Price : ");
double bookPrice = input.nextDouble();
System.out.println("The Book Category is: " + bookId);
System.out.println("The Book Price is: " + bookPrice);
input.close();
}
public static void getInputFromReader() {
BufferedReader dataIn = new BufferedReader(new InputStreamReader( System.in) );
String bookTitle = "";
System.out.print("Enter book title");
here below it: I want to change the bookCategory from String to char, but if I change, I have received a lots of error. It's like a string when in run but I have to change only a bookCategory from String to char.
String bookCategory = "";
System.out.print("Enter book title");
try {
bookTitle = dataIn.readLine();
bookCategory = dataIn.readLine();
}catch(IOException e) {
System.out.println("Error!");
}
System.out.println("The book title is: " + bookTitle);
System.out.println("The book category is: " + bookCategory);
}
public static void main(String[]args) {
getInputFromReader();
getInputFromScanner();
}
}