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
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();
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
There are a few issues with your code Lets go through them one by one 1 In the Textbookinformation i...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started