1. (25 points) For this question, first download the file called campers.txt and add it to your project as shown in clas

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

1. (25 points) For this question, first download the file called campers.txt and add it to your project as shown in clas

Post by answerhappygod »

1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 1
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 1 (65.18 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 2
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 2 (65.18 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 3
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 3 (60.87 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 4
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 4 (21.46 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 5
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 5 (33.45 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 6
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 6 (33.45 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 7
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 7 (27.33 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 8
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 8 (41.04 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 9
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 9 (40.08 KiB) Viewed 28 times
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 10
1 25 Points For This Question First Download The File Called Campers Txt And Add It To Your Project As Shown In Clas 10 (36.37 KiB) Viewed 28 times
1. (25 points) For this question, first download the file called campers.txt and add it to your project as shown in class. Then write a program that does the following: 1.1. Open the file provided called campers.txt for input. Create 2 ArrayLists. The first will hold the student name which is a String and the second ArrayList will hold the camper age which is an int Use a while loop to input 2 pieces of data at a time from the file (Open campers.txt to see how it's formatted). Each line represents a single camper. Loop should end when there are no more lines in the file Add the camper age to the ArrayList holding ages Add the camper name to the ArrayList holding names 1.2. After you fall out of the while loop - close the file • Output a string to indicate what each column holds (Name Age) Use a loop to print out the information for each student on a single line from the two ArrayLists Example Output Name Age Masarra 10 Abbas 11 1.3. After you fall out of the for loop use another loop to loop through all the ages stored in the camper age ArrayList - Sum up the ages When the loop finishes print out average age of the campers with precision of 1 as shown below: Average age is 12.5 2. (25 points) Modify the BookStore and Book Search Engine classes explained in the class to include the following additional methods and test them: a) A method returning the book with the lowest price in the library. b) A method searching the library for Books of a given author and returning an ArrayList of such Books c) A method returning an ArrayList of Books whose price is less than a given number.
Style Use white space (Indentation, blank lines) to show the program structure. All variable and constant names will be meaningful and will follow naming conventions. Include all variable declarations and add a comment next to each variable as to its purpose. You will lose points if you have not added comments. On top of each program should have the following comments: Name: * Date: * Question number: * Description: Deliverables You create a program for each question then compress your projects all in a zip file with your lastname and homework number (Lastname_HW#) and submit the zip file on Moodle. Getting ready to demo your lab to your lab mentor The interview is 40% of your lab grade. Make sure to be prepared for your mentor's questions about your program. When it is your tum to explain your lab to your lab mentor follow these steps, make sure that your lab mentor sees the following steps: 1. Log on to Moodle. 2. Find your submission link for this lab. 3. Download your Lab on your computer 4. Find your lab wherever you downloaded. 5. Make sure to Unzip, (or extract) your folder 6. Open the solution file to demo your lab. You must follow these steps each time you are being graded for your lab. Your lab mentor must confirm that you downloaded what was submitted on Moodle. You should be graded on what was uploaded on Moodle not on a local copy obtained from your C drive or external drives (i.e., с memory sticks).
10 Masarra 11 Abbas 11 Natly 12 Ethan 15 Terry 13 Peter 14 Brent 10 Matthew 13 Johan 12 Mikayle 14 Bernard 11 Patty 15 Garrett 12 Bryan 12 Hunter 15 Joel 14 James 12 Maxim 10 Malika 14 Nick 13 Casey 14 Alexis 10 Joshua 11 Joshua 11 Philip 13 Jeremy 15 Noah
10:35 ul 5G Done Book (1 of 3) package bookarraylist; * Click nbfs://nbhost/SystemFilesystem/ Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFilesystem/ Templates/Classes/Class.java to edit this template public class Book { private String title; private String author; private double price; /** default constructor */ public Book() { title = ""; author = ""; price = 0.0; /** overloaded constructor @param title the value to assign to title @param author the value to assign to author * @param price the value to assign to price public Book String title, String author, double price ) { this.title = title; this.author = author; this.price = price; } /** getTitle method @return the title public String getTitle() H E
10:35 al 5G { * */ { * */ Done Book (1 of 3) pubic Bookt string title, string autnor, double price ) this.title = title; this.author = author; this.price = price; } /** getTitle method @return the title public String getTitle) return title; } /** getAuthor method @return the author public String getAuthor() return author; } /** getPrice method @return the price public double getPrice() { return price; } /** toString * @return title, author, and price */ @Override public String toString() { return( "title: " + title + "\t" "author: " + author + "\t" "price: " + price ); { } III
10:35 ul 5G Done BookArrayList (2 of 3) * Click nbfs://nbhost/SystemFilesystem/ Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFilesystem/ Templates/Classes/Main.java to edit this template */ package bookarraylist; import java.util.*; public class BookArrayList { * @param args the command line arguments */ public static void main(String[] args) { BookStore bs = new BookStore(); Scanner scan = new Scanner(System.in); System.out.print( "Enter a keyword > " ); String keyword = scan.next(); System.out.println("Our book collection is:" ); // using toString method to return the list of books System.out.println( bs.toString()); ArrayList<Book> results = bs.searchForTitle keyword ); // calling the searchForTitle by passing the keyword parameter System.out.println("The search results for + keyword + " are:" ); for ( Book tempBook : results) System.out.println( tempBook.toString(); } U III
10:35 .11 5G Done BookStore (3 of 3) * Click nbfs://nbhost/SystemFilesystem/ Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFilesystem/ Templates/Classes/class.java to edit this template */ package bookarraylist; import java.util.*; public class BookStore { // collection of books private ArrayList<Book> library; /** default constructor instantiates ArrayList of Books */ public BookStore) { library = new ArrayList<Book> (); library.add( new Book( "Intro to Java", "James", 56.99 ) ); library.add(new Book "Advanced Java", "Green", 65.99 ) ); library.add(new Book ( "Java Servlets". "Brown", 75.99 ) ); library.add(new Book "Intro to HTML". "James", 29.49 ) ); library.add(new Book( "Intro to Flash", "James", 34.99 ) ); library.add(new Book "Advanced HTML", "Green", 56.99 ) ); } /** toString @return each book in library, one per line @Override public String toString() { String result = ""; farl Deals AMD Al. 15 hari III
10:35 ul 5G Done BookStore (3 of 3) } { /** tostring @return each book in library, one per line */ @Override public String toString() String result = ""; for ( Book tempBook : library { result += tempBook.toString() + "\n"; return result; : } } */ /** Generates list of books containing searchString @param searchString the keyword to search for Oreturn the ArrayList of books containing the keyword public ArrayList<Book> searchForTitlet String searchString) { // object of ArrayList ArrayList<Book> searchResult = new ArrayList<Book>(); // use for loop to go through book in the list for ( Book currentBook : library) { // if the title is matched with what is in the ArrayList if ( currentBook.getTitle().indexOf( searchString ) != -1 ) searchResult.add( currentBook ); } return searchResult; E
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply