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 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...
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...
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...
Hi I am having the following problem. At the moment I am trying to create a...
Hi I am having the following problem. At the moment I am trying to create a bode plot for the following function. G(s)=(Ks+3)/((s+2)(s+3)) Note: Not K(s+2)! I then want to plot multiple bode plots for various values of K. Eg. 1,2,3, etc. I am having two separate issues. 1. How do I define the TF with a constant K in the location required (a multiple of s in the numerator) 2. How do I create multiple bode plots for values...
Given a doubly linked list in c++, how do I create a function that returns the...
Given a doubly linked list in c++, how do I create a function that returns the pointer to first node in the given pattern, For example, given mainList (a -> b -> c -> d) and sublist  (b -> c), our function should return a Node pointer that points to first node of the sublist in the mainList. If the pattern doesn't exist in the mainList, we should return a nullptr, there are multiple of the same sublist in the mainList,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT