Question

In: Computer Science

My apologies, This is actually the question I was referring too.. It wants the pseudocode aswell...

My apologies, This is actually the question I was referring too.. It wants the pseudocode aswell as the flowchart which I am having trouble with the psedocode and what responses I have seen to the question has not made a ton of sense. Any help woudl be apprecitated. Thank you

a. Registration workers at a conference for authors of children’s books have collected data about conference participants, including the number of books each author has written and the target age of their readers. The participants have written from 1 to 40 books each, and target readers’ages range from 0 through 16. Design a program that continuously accepts the number of books written until a sentinel value is entered, and then displays a list of how many participants have written each number of books (1 through 40). b. Modify the author registration program so that a target age for each author’s audience is input until a sentinel value is entered. The output is a count of the number of books written for each of the following age groups: under 3, 3 through 7, 8 through 10, 11 through 13, and 14 and older.

Solutions

Expert Solution

Included both a and b solutions....

import java.util.*;
public class Author {
// class variables
String name;
int age;
ArrayList<String> books = new ArrayList<>();
  
// constructor
public Author(String name, int age,String book) {
books.add(book);
this.name = name;
this.age = age;
}
  
// add book
public void addBook(String book) {
books.add(book);
}
// get books
public int totalBooks() {
return books.size();
}
  
// print books
public void printAuthorBooks() {
System.out.println("Author books are: ");
for(int i=0;i<books.size();i++) {
System.out.println(books.get(i));
}
}
  
// main
public static void main(String args[]) {
//reading author data
int[] ageBooks = new int[40];
// initalizing array elements to zero
for(int i=0;i<40;i++) {
ageBooks[i] = 0;
}
Scanner sc = new Scanner(System.in);
Scanner sc1 = new Scanner(System.in);
while(true) {
// printing menu
System.out.println("1.Register new author 2.Get count of books of each age 3.exit");
//reading input
int choice = sc.nextInt();
if(choice == 1) {
System.out.println("Enter name: ");
String name = sc1.nextLine();
System.out.println("Enter age: ");
int age = sc.nextInt();
ageBooks[age-1]++;
System.out.println("Add book :");
String book = sc1.nextLine();
// creating object
Author obj = new Author(name,age,book);
// displaying anoher menu
while(true) {
System.out.println("1.Add more book 2.display books 3.exit ");
int choice2 = sc.nextInt();
if(choice2 == 1) {
System.out.println("Add book :");
String book1 = sc1.nextLine();
ageBooks[age-1]++;
obj.addBook(book);
}
else if(choice == 2){
obj.printAuthorBooks();
}
else{
System.out.println("Good bye");
break;
}
}
}
else if(choice == 2){
// diaplaying number of books as per age
for(int i=0;i<40;i++) {
if(ageBooks[i] > 0){
System.out.println("Age: "+i+" -> "+ageBooks[i]);
}
}
}
else {
System.out.println("Good bye");
break;
}
}
}
}

OUTPUT


Related Solutions

Can someone write me, in pseudocode, and it doesn't have to be modular, actually, I prefer...
Can someone write me, in pseudocode, and it doesn't have to be modular, actually, I prefer it not to be modular, for the following question below: If a moderately active person cuts their calorie intake by 500 calories a day, he or she can typically lose about 4 pounds a month. Write a program that has the user enter their starting weight and then displays a table showing what their expected weight will be at the end of each month...
question is referring to SF2. i drew the lewis structure and the question is what orbital...
question is referring to SF2. i drew the lewis structure and the question is what orbital of F only has one valence electron in it? draw this orbital of flourine overlapping with the hybrid orbital drawn overlapping with the hybrid orbital of sulfur. I know that the electron configuration of F is [He} 2s2 2p5 so the third orbital of p has ONE valence electron but i don't know how to draw the hybrid orbitals of F and S
I actually would like you to take a look at my code and point it out...
I actually would like you to take a look at my code and point it out if there is anything wrong with it. I think there might be because there are some values that are the same in different arrays. QUESTION: C++ Use the random number generator in class Random to store a list of 1000 random integer values in an array. Create 3 arrays using this method. Apply each of the insertion, bubble, selection and shell sort algorithms to...
Discussion: I, Pencil "Actually, millions of human beings have had a hand in my creation, no...
Discussion: I, Pencil "Actually, millions of human beings have had a hand in my creation, no one of whom even knows more than a very few of the others." – Leonard E. Read Think about this quote, before, during, and after you read the essay, “I, Pencil.” For this discussion, I would like you to reflect upon this quote and the essay to answer and participate in a discussion about the following: How is the creation of a technology actually...
Hi, I submitted this question before, but it wasn't actually answered. I figured out 1 and...
Hi, I submitted this question before, but it wasn't actually answered. I figured out 1 and 2, but can you try the rest? I am unsure how to solve it. TufStuff, Inc., sells a wide range of drums, bins, boxes, and other containers that are used in the chemical industry. One of the company’s products is a heavy-duty corrosion-resistant metal drum, called the WVD drum, used to store toxic wastes. Production is constrained by the capacity of an automated welding...
After take a cup of the coffee i feel my head weight is too high very...
After take a cup of the coffee i feel my head weight is too high very uncomfortable feeling. hyper sensitivity. head top is not feel when touch. what reason? i am magrine patient. caffine is bad for magrine. but i use coffee when i am 10 year old now 22.
The data table is too large to be put in the question here is where I...
The data table is too large to be put in the question here is where I collected the data: Visit the NASDAQ historical prices weblink(https://finance.yahoo.com/quote/GOOG/history/). First, set the date range to be for 1.16.18- 2.15.19. [Do this by clicking on the blue dates after “Time Period”. Next, click the “Apply” button. Next, click the link on the right side of the page that says “Download Data” to save the file to your computer]. Normal distribution Average=1110.68525 Standard Deviation= 65.5518337 Mode=...
I need a answer to my professors question about my discussion post My Post 1) What...
I need a answer to my professors question about my discussion post My Post 1) What types are protected? Under the National Labor Relation Act, an employee's right to strike is a considered as a critical component of the right to organize. But to ensure balance this right is not without limitations. As per Section 7 of NLRA only Certain strikes qualify as protected activity. These recognized strikes are: ·         Unfair labor practice strikes, which protest employers illegal activities. ·        ...
I am not aware of GR, but due to curiosity i have a question in my...
I am not aware of GR, but due to curiosity i have a question in my mind. Please let me know if it is inappropriate to ask here. My question is about singularity. I am under the assumption that singularity means in mathematical terms equivalent to a discontinuity in a function. My question is what type of discontinuity are the ones corresponding to Penrose-Hawking singularity theorems and also to the the naked singularity ? by type i mean removable (left...
I actually did question 1-7, but I do have some problems in 8 and 9. part...
I actually did question 1-7, but I do have some problems in 8 and 9. part I: Project Rescue (25 points) The Park Rangers protecting our national forests typically carry communication and sighting equipment that is used to help locate lost hikers, forest fires, airplanes crashes and other such like. In one instance, a light plane P crashed in a dense part of the forest, with the crash occurring to the northeast of a ranger R who witnessed the event....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT