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
True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript. Tru
Dahasolnce [82]

Answer:

True

Explanation:

3 0
2 years ago
Write an application that displays appropriate prompts to the user and reads a person
vfiekz [6]

Answer:

The program to this question can be given as:

Program:

import java.util.*; //import package  

public class Person_detail //define class

{

public static void main(String ar[]) //define main function

{

String Name,hobby,dream_Job; //declare variable.

int age;

Scanner sc = new Scanner(System.in); //creating Scanner class object for user input.

System.out.print("Enter Your Name : "); //message  

name = sc.next(); //user input

System.out.print("Enter Your Age : ");

age = sc.nextInt();

System.out.print("Enter Your hobby: ");

hobby = sc.next();

System.out.print("Enter Your aim: ");

aim = sc.next();

//print values.

System.out.println("Hello, my name is "+name+" and I am "+age);

System.out.println("years old.My hobby is playing "+hobby+".");

System.out.println("I want to be a "+aim+" when I grow up!");

}

}

Output:

Hello, my name is XXX and I am 21

years old.My hobby is playing cricket .

I want to be a cricketer when I grow up!.

Explanation:

In the above program firstly we import the package for user input. Then we declare a class that is Person_detail. In this class, we declare the main function. In the main function, we declare a variable that is name, hobby, aim, and age. In these variable first 3 variables datatype is string and age variable data type in integer. Then we create a scanner class object and take input from the user and print it into a paragraph.

3 0
2 years ago
One advantage of taking photographs under fluorescent light is that: Group of answer choices
Alexus [3.1K]

They tend to be dull.

7 0
2 years ago
The force that pulls away from a curve is known as
77julia77 [94]

The correct answer is centrifugal force.

The force that pulls out from the center on a body that is in a circular motion is called centrifugal force. This force increases as the speed of motion increases. It is centrifugal force that results in a strong outward pull on your vehicle traveling around a corner.

7 0
3 years ago
What is the next line?
jonny [76]

Answer:

Answered below

Explanation:

The next line is 1.

The python count function returns the number of times an element appears in a tuple or a list.

In the tupleB tuple, 7 is passed into the count function. The number of times 7 appears in tupleB is just once alongside 5, 2.7, 10 and 5. Therefore, the count function returns 1 in the next line.

5 0
2 years ago
Other questions:
  • 14. Which commercial RDBMS product was the first to hit the market and is the biggest?
    15·1 answer
  • Pointsyour company environment includes windows server versions 2003, 2008, and 2012. desktops range from windows xp and vista.
    13·1 answer
  • You are evaluating the bounce rate of your overall website traffic and find that users with a social media referral source have
    9·1 answer
  • The work day has just started and you receive reports that the inventory management server is not accessible on your company's n
    7·1 answer
  • How can the use of new technology in industry benefit the us government
    8·2 answers
  • The question of ________ arises when considering the way in which online marketers gather consumers’ information over the Intern
    6·1 answer
  • One tool under What-If-Analysis is Scenarios. Which best describes the purpose of setting up and using scenarios
    5·1 answer
  • What is also known as computer Network?
    6·2 answers
  • Which types of file formats are the best choice for files that may need to be edited later?
    14·1 answer
  • you want to upgrade your windows 10 professional computer to windows 11 professional. you begin by checking the hardware and dis
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!