I need to use interfaces and user input for textbook information. Something feels off about my code
Question:
I need to use interfaces and user input for textbook information. Something feels off about my code and working with interfaces is something brand new for me.
Create a java program using interfaces to display your textbook information
import java.util.*;
interface Textbookinformation {
Scanner sc = new Scanner(System.in);
String title = ("");
String author = ("");
String publicationyear = ("");
String edition = ("");
}
public class Textbook implements Textbookinformation {
public static void main (String[] args)
{
Textbook myTextbook = new Textbook();
myTextbook.title();
myTextbook.author();
myTextbook.publicationyear();
myTextbook.edition();
}
public void title()
{
System.out.println(" What is the title of the textbook?");
String title = sc.next();
}
public void author()
{
System.out.println(" What is the name of the author? ");
String author = sc.next();
}
public void publicationyear()
{
System.out.println(" What is the publication year of the textbook?");
String publicationyear = sc.next();
}
public void edition()
{
System.out.println(" What edition is the textbook?");
String edition = sc.next();
}
}
Applying Communication Theory For Professional Life A Practical Introduction
ISBN: 9781506315478
4th Edition
Authors: Marianne Dainton, Elaine D. Zelley