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
If one employee is assigned to a project and each project has only one employee working on it, there is a(n) ____ relationship b
Len [333]

Answer:

One-to-one is the answer because there is one project and one employee working on one project.

5 0
2 years ago
Which loan type requires you to make loan payments while you’re attending school?
Levart [38]
<span>A:Unsubsidized federal loan</span>
7 0
3 years ago
Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two
natka813 [3]

Answer:

tyhgfrd

Explanation:

8 0
3 years ago
One goal of networking is to:
malfutka [58]
To further your employment opportunities
8 0
3 years ago
Read 2 more answers
I have a question about this programming assignment. The outcome when the user puts in Taylor for guest one and Fernando for gue
ivolga24 [154]
Yes u need more brackets
4 0
3 years ago
Read 2 more answers
Other questions:
  • What are the coordinates of (3 comma space 8 )relative to the basis open curly brackets space (1 comma space 1 )comma space (0 c
    15·1 answer
  • Dwight <br> d. eisenhower was impressed with germany's network of highways and how it __________.
    15·1 answer
  • _____ remove the part of an image starting from an edge​
    13·1 answer
  • What does the CPU do in a computer?
    7·2 answers
  • Which leader of the Jamestown colony am I?
    15·2 answers
  • Which browser should you choose if you want all viewing information except thumbnail previews of websites?
    15·2 answers
  • The Department Manager researches new data platforms for the company and requests a list of essential features. Which essential
    6·1 answer
  • Your supervisor has asked you if it is possible to monitor servers for potential port scans via SNMP. What two OIDs can you prov
    13·1 answer
  • WILL GIVE A BRAINLIEST!!! PLS HELP!!!
    5·1 answer
  • Question #4
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!