1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sweet [91]
1 year ago
8

Given the following class, Book, Write code for the following:

Computers and Technology
1 answer:
Yuri [45]1 year ago
7 0

Using the knowledge in computational language in JAVA it is possible to write a code that can organize the books in price and author classes.

<h3>Writing the code in JAVA we have:</h3>

<em>class Book{</em>

<em>    private int price;</em>

<em>    private String author;</em>

<em>    public Book(int p){</em>

<em>        price=p;</em>

<em>    }</em>

<em>    public Book(Book b){</em>

<em>        price=b.price;</em>

<em>        author=b.author;</em>

<em>    }</em>

<em>    public int getPrice(){</em>

<em>        return price;</em>

<em>    }</em>

<em>    public void setAuthor(String a){</em>

<em>        author=a;</em>

<em>    }</em>

<em>    public String toString(){</em>

<em>        return author+" "+Integer.toString(price);</em>

<em>    }</em>

<em>}</em>

<em>public class Main</em>

<em>{</em>

<em> public static void main(String[] args) {</em>

<em>     Book b=new Book(450);</em>

<em>     b.setAuthor("Jack");</em>

<em>     Book b1=new Book(b);</em>

<em>     System.out.println(b1.toString());</em>

<em> }</em>

<em>}</em>

See more about JAVA at brainly.com/question/18502436

#SPJ1

You might be interested in
I’m so lost. which username do i do.
koban [17]

Answer:

the username you feel like using

5 0
2 years ago
Read 2 more answers
The basic form of backup used in magnetic tape operations is called
Harrizon [31]
Answer is the son-father-grandfather concept. Good luck
5 0
2 years ago
Exodia<br>Principle of Computer Operation​
tamaranim1 [39]

Answer:

????

Explanation:

6 0
3 years ago
What is the name of the fifth Sims 3 expansion pack
olga2289 [7]
2 were released as part 5 for the Sims 3 Expansion Pack Series. These two packs were the Pets Expansion and the Master Suite pack which added buyable and ownable pets and hotels.
8 0
2 years ago
When designing a slide for presentation, it is best to include as much information as possible on every slide. True Or False
Mariulka [41]

Answer:

false

Explanation:

try to limit the amount of info on each slide

4 0
3 years ago
Read 2 more answers
Other questions:
  • PLC software does not typically fail or break​
    15·1 answer
  • Given an array declared to hold 100 values, the smallest index that can be used with the array is
    7·1 answer
  • 12. In 2009, __________ of all pedestrian fatalities were caused by impaired drivers
    9·2 answers
  • To enter a typed number into a cell, you press Tab or Backspace?​
    7·2 answers
  • Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output tho
    9·1 answer
  • If your network consists of all connected devices connecting to one central device, such as a switch, what type of topology is b
    8·1 answer
  • In what stage of an algae or fungi life cycle are they able to reproduce spores?
    10·1 answer
  • Write a program in C/C++ to draw the following points: (0.0,0.0), (20.0,0.0), (20.0,20.0), (0.0,20.0) and (10.0,25.0). For this
    6·1 answer
  • Only one person can receive the same email at the same time true or false
    10·1 answer
  • 2.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!