Question

In: Computer Science

Im trying to create a book list. I started off like this but idk how to...

Im trying to create a book list. I started off like this but idk how to continue?

public static int [] BookList (String title, String author, int price, int copies, String category) {

}

I don't know what to do next in order to list a set of (lets say 5 ) books and how to call it in the main (public static void main(String[] args))method

Solutions

Expert Solution

public static int [] BookList (String title, String author, int price, int copies, String category) {

}

Return list type cannot int because we have both Strings and int values in method.To combine the values and to return the list,List type should be String.I have given the code to call the method from main method.

Java Code :

import java.lang.*;
class Books{
   public static String []BookList(String title,String author,int price,int copies,String category){
       String list[] = new String[5];
       list[0] = title;
       list[1] = author;
       list[2] = String.valueOf(price);
       list[3] = String.valueOf(copies);
       list[4] = category;
       return list;
   }
   public static void main(String args[]){
       String list[] = new String[5];
       list = Books.BookList("Wings of Fire","A.P.J.Abdul Kalam",400,10,"Autobiography");
      
       System.out.println("Book Details\n");
       System.out.println("Title : " + list[0]);
       System.out.println("Author : " + list[1]);
       System.out.println("price : " + list[2] + " Rupees");
       System.out.println("Copies : " + list[3]);
       System.out.println("Category : " + list[4]);
   }
}

Output :

Please Up vote.Thank You.


Related Solutions

I get an error when im trying to run this java program, I would appreciate if...
I get an error when im trying to run this java program, I would appreciate if someone helped me asap, I will make sure to leave a good review. thank you in advance! java class Node public class Node { private char item; private Node next; Object getNext; public Node(){    item = ' '; next = null; } public Node(char newItem) { setItem(newItem); next = null; } public Node(char newItem, Node newNext){ setItem(newItem); setNext(newNext); } public void setItem(char newItem){...
Coding in R Im trying to plot a histogram in R, and i know the basic...
Coding in R Im trying to plot a histogram in R, and i know the basic code for that, however, the code requires 2 plots coming from the same data set. for example, the voltage of an old process vs. a new process. is there any ways to seperate the 2 processes out from the data set to make 2 relative frequencyt histograms?
In trying to apply my knowledge in the real world, I am trying to create a...
In trying to apply my knowledge in the real world, I am trying to create a realistic retirement schedule. However, I am running into difficulties using both a financial calculator as well as our equations from class in doing this. I am trying to do the following: plan a retirement schedule between the ages of 25 and 70, in which I would deposit 20% of my income each year. The income starts at 80,000 with an annual growth rate of...
I need this code translated from C++ to Java. Im personally still trying to learn Java,...
I need this code translated from C++ to Java. Im personally still trying to learn Java, so if you can include screenshots of your IDE/output that would be helpful. Much appreciated! #include <iostream> #include <string> using namespace std; class pizza { public:    string ingrediants, address;    pizza *next;    pizza(string ingrediants, string address)    {        this->address = address;        this->ingrediants = ingrediants;        next = NULL;    } }; void enqueue(pizza **head, pizza **tail, pizza...
Im trying to run Nmap vulnerability scrip on Kali to my Metasploitable VM. Every time I...
Im trying to run Nmap vulnerability scrip on Kali to my Metasploitable VM. Every time I use : Nmap --script vulnerability (IP address) I get back following response: |_clamav-execl: error: Script execution failed (use -d to debug) Trying to solve this issue please help. Ps: I already updated my Nmap and still gives the same issue.
I am trying to make a Risk Management tool in Python. I have it partially started....
I am trying to make a Risk Management tool in Python. I have it partially started. The scenario is that the Project Manager needs to be able to log on and enter information ( the required information is located in the code). I then need to capture that data and store it in an array with the ability to call back and make changes if necessary. Could you please help me out and explain what was done? Current code: Start...
Im trying to figure out how to draw this Now, in the innermost circle (0.1 m...
Im trying to figure out how to draw this Now, in the innermost circle (0.1 m radius), assume we found 8 species of plant. In the second smallest circle, we found 10 species. In the third smallest circle, we found 13 species. In the largest circle, we found 14 species. Note that when moving from the smallest circle to the next-smallest circle, we did NOT find 10 additional species...The 10 species in the second smallest circle includes the 8 found...
Professor, In trying to apply my knowledge in the real world, I am trying to create...
Professor, In trying to apply my knowledge in the real world, I am trying to create a realistic retirement schedule. However, I am running into difficulties using both a financial calculator as well as our equations from class in doing this. I am trying to do the following: plan a retirement schedule between the ages of 22 and 68, in which I would deposit 25% of my income each year. The income starts at 80,000 with an annual growth rate...
Hi, Im doing my final project for quanatative analysis class. I was tasked to create a...
Hi, Im doing my final project for quanatative analysis class. I was tasked to create a regression analysis on Does the number of probowl player have bearing on becoming all pro. I ran the regression for the following data and got this output from Megastat but I'm not sure what it tells me. Regression Analysis r² 0.006 n   239 r   0.076 k   1 Std. Error   0.494 Dep. Var. All Pro ANOVA table Source SS   df   MS F p-value Regression 0.3397...
I am trying to create bit masks to create a new binary number with the original...
I am trying to create bit masks to create a new binary number with the original bits' orders turned around, and concataneted. For example, int test=0b01100010001010001001(20 bits) now, I need bit masking to make it: int result = 20th bit, 10-1 bits, 11th bit, 19-12 bits, in this order. So in this case, answer would be: 0(20th bit)10100010(10-1 bits)0(11th bit)1011000100(19-12 bits). Im trying to do something like int res |= test & 0x7F800; res |= test& 0x400; Can't seem to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT