CSE 1321L: Programming and Problem Solving | Lab Assignment 5 - 100 points What students will...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
CSE 1321L: Programming and Problem Solving | Lab Assignment 5 - 100 points What students will learn: 1) Declaring arrays 2) Initializing arrays 1D & 2D Arrays 3) Performing common operations on arrays Overview: Arrays are an incredibly powerful thing in computing. Almost every audio file, video file, and image you've ever seen on a computer is stored in an array. An array is simply a data structure that holds a lot of things of the same type (i.e., it is homogeneous). For example, they could hold 50 integers, 100 Booleans, or a million floats. For most languages, when you see brackets [ ], you know you're working with an array. Assignment 5A: Top 5. In the ancient days of social media, there was a concept of a "Top 5" friends list. You would add (or remove) friends from your Top 5 list, which was displayed on your profile page. Fierce wars were fought over what order your friends listed you - and vice versa. We're going to use 1D arrays to recreate some of this experience. You will create a 1D String array of size 5. You will then create a loop that gives the following options: • Enter a friend's name • Replace a friend's name • • Quit Display your current friends list When you enter a friend's name, it should be added to the next empty slot in the array (E.g. if you've entered two names, you would add the next name to index 2). The program should not let you enter duplicate names (case sensitive) or enter any more names once your array is full. When you replace a name, you should prompt the user for a new name and an index. You will then change the value at that index with the name the user enters. If the name or index does not exist in the array, notify the user. Display your friend's names from 1 to 5, one name per line. If no one is listed at the array index, just print the number and empty space. If the user chooses Quit, end the loop and stop the program. You must use a 1D array for this assignment; you will not earn points if you do not use a 1D array. Sample Output: [Top 5 Friend's List] What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Kret low What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Sullivan What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 3 Friend's List: 1) Kret low 2) Sullivan 3) 4) 5) What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Kret low Sorry, they're already on the list! //Imagine we've already filled the list <Don't print this> What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Murphy Sorry, your friends list is full! What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 2 Enter a name: Malcolm Enter an index: 3 Malcolm has replaced Scrappy on your friends list! What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 2 Enter a name: Mamo Enter an index: 13 Sorry, that's an invalid command! What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 3 Friend's List: 1) Kretlow 2) Sullivan Assignment 5B: What's your sign? We can use 2D arrays as a kind of “look-up table". This means we can fill it with information, and quickly access relevant data using the index numbers. First, you will create a 2D String array – the rows will represent the 12 months of the year, and the columns will represent the days of each month (you may either use 31 days as the boundary for each row, or use ragged arrays). You will fill each cell with the appropriate Zodiac sign, using the ranges shown here: https://www.britannica.com/topic/zodiac For example, 10/14 would be "Libra". You will then prompt the user to enter their day and month of birth using integers (e.g. October is 10). You will use these values as indexes to get the correct sign from the 2D array. Make sure to check if the input would be outside the range of the array. You must use a 2D array for this assignment; you will not earn points if you do not use a 2D array. Sample Output #1: [What's your sign?] What month were you born in? 11 And what day? 24 Your sign is Sagittarius! 3) Mamo 4) Malcolm 5) Lab Instructor What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 4 [Program Ends] Sample Output #2: [What's your sign?] What month were you born in? 32 That is not a valid month... Sample Output #3: [What's your sign?] What month were you born in? 11 And what day? -32 That is not a valid day... Submission: 1. You will submit 2 separate files 2. File names and class names must be correct. 3. Upload all files (simultaneously) to the assignment submission folder in Gradescope. CSE 1321L: Programming and Problem Solving | Lab Assignment 5 - 100 points What students will learn: 1) Declaring arrays 2) Initializing arrays 1D & 2D Arrays 3) Performing common operations on arrays Overview: Arrays are an incredibly powerful thing in computing. Almost every audio file, video file, and image you've ever seen on a computer is stored in an array. An array is simply a data structure that holds a lot of things of the same type (i.e., it is homogeneous). For example, they could hold 50 integers, 100 Booleans, or a million floats. For most languages, when you see brackets [ ], you know you're working with an array. Assignment 5A: Top 5. In the ancient days of social media, there was a concept of a "Top 5" friends list. You would add (or remove) friends from your Top 5 list, which was displayed on your profile page. Fierce wars were fought over what order your friends listed you - and vice versa. We're going to use 1D arrays to recreate some of this experience. You will create a 1D String array of size 5. You will then create a loop that gives the following options: • Enter a friend's name • Replace a friend's name • • Quit Display your current friends list When you enter a friend's name, it should be added to the next empty slot in the array (E.g. if you've entered two names, you would add the next name to index 2). The program should not let you enter duplicate names (case sensitive) or enter any more names once your array is full. When you replace a name, you should prompt the user for a new name and an index. You will then change the value at that index with the name the user enters. If the name or index does not exist in the array, notify the user. Display your friend's names from 1 to 5, one name per line. If no one is listed at the array index, just print the number and empty space. If the user chooses Quit, end the loop and stop the program. You must use a 1D array for this assignment; you will not earn points if you do not use a 1D array. Sample Output: [Top 5 Friend's List] What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Kret low What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Sullivan What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 3 Friend's List: 1) Kret low 2) Sullivan 3) 4) 5) What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Kret low Sorry, they're already on the list! //Imagine we've already filled the list <Don't print this> What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 1 Enter a name: Murphy Sorry, your friends list is full! What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 2 Enter a name: Malcolm Enter an index: 3 Malcolm has replaced Scrappy on your friends list! What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 2 Enter a name: Mamo Enter an index: 13 Sorry, that's an invalid command! What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 3 Friend's List: 1) Kretlow 2) Sullivan Assignment 5B: What's your sign? We can use 2D arrays as a kind of “look-up table". This means we can fill it with information, and quickly access relevant data using the index numbers. First, you will create a 2D String array – the rows will represent the 12 months of the year, and the columns will represent the days of each month (you may either use 31 days as the boundary for each row, or use ragged arrays). You will fill each cell with the appropriate Zodiac sign, using the ranges shown here: https://www.britannica.com/topic/zodiac For example, 10/14 would be "Libra". You will then prompt the user to enter their day and month of birth using integers (e.g. October is 10). You will use these values as indexes to get the correct sign from the 2D array. Make sure to check if the input would be outside the range of the array. You must use a 2D array for this assignment; you will not earn points if you do not use a 2D array. Sample Output #1: [What's your sign?] What month were you born in? 11 And what day? 24 Your sign is Sagittarius! 3) Mamo 4) Malcolm 5) Lab Instructor What would you like to do? 1) Enter a friend's name 2) Replace a friend's name 3) Display your friends list 4) Quit Your choice: 4 [Program Ends] Sample Output #2: [What's your sign?] What month were you born in? 32 That is not a valid month... Sample Output #3: [What's your sign?] What month were you born in? 11 And what day? -32 That is not a valid day... Submission: 1. You will submit 2 separate files 2. File names and class names must be correct. 3. Upload all files (simultaneously) to the assignment submission folder in Gradescope.
Expert Answer:
Answer rating: 100% (QA)
To solve the lab assignments described above youll need to write Java programs Heres a guide for each assignment Assignment 5A Top 5 Friends List 1 Cr... View the full answer
Related Book For
Financial Reporting Financial Statement Analysis and Valuation a strategic perspective
ISBN: 978-1285190907
8th edition
Authors: James M. Wahlen, Stephen P. Baginski, Mark Bradshaw
Posted Date:
Students also viewed these programming questions
-
Consider the following population regression model: y = Bo + Bx + Bx2 + 3x3 + u Suppose you want to test whether 0.532 = 83. The hypotheses are: Ho : 0.582 = 33 H : 0.532 #33 The correct expression...
-
The Schuyler Corporation manufactures lamps. It has set up the following standards per finished unit for direct materials and direct manufacturing labor: Direct materials: 10 lb. at $4.50 per lb. ....
-
According to Statistics Canada, the average hourly wages in the manufacturing sector are as follows: Alberta: $26.50, Ontario: $24.69, British Columbia: $26.47.6 Suppose 40 workers are selected...
-
Bernardino Santos-Rodiguez was piloting a boat owned by his friend, Raul Viera-Torres, in waters near Guayama, Puerto Rico. The boat was equipped with a hydraulic steering system manufactured by...
-
(a) Given the product structure and master production schedule (Figure 14.14 below), develop a gross requirements plan for all items. (b) Given the preceding product structure, master production...
-
List and describe/discuss the five advantages of intermediate sanctions over traditional probation or incarceration.
-
Sheridan Paintball records adjusting entries on an annual basis. The company has the following information available on accruals that must be recorded for the year ended June 30, 2021. 1. Sheridan...
-
Two heat capacities are defined: the heat capacity at constant volume (CV) and the heat capacity at constant pressure (Cp). The formal definitions of these parameters are: Cy= CP= = = aq V;N (2) (3)...
-
Housekeeping Services at Omega Hospital provided janitorial services to three wards during 2014 at a direct cost of $100,000. The square footage of each ward and hours of housekeeping are provided...
-
Cow-Calf Budget Spring Calving, Sell at 225 days of age Feeder Calf Sale $340 Total revenue Income over variable costs $30999 Profit $30694 Breakeven selling price needed for the feeder calf to pay...
-
Search for cut off/standard ratio for merchandising businesses At least 2 links resources per ratio Profitability a. Net Profit Margin b. Gross Profit Margin c. Operating Profit Margin d. Return on...
-
what is the Nikeinventory reserve? Nike make ongoing estimates relating to the net realizable value of inventories based upon our assumptions about future demand and market conditions. If we estimate...
-
A living will: Question 27 options: Expresses the client's desire to transfer assets to designated heirs. Requires a court to appoint a Guardian for an incompetent person. Expresses the client's...
-
Calculate the pH of the following solutions (<5% error): a) HF 0.01 M. b) NH4Cl 0.01 M. c) 0.01 M ammonium acetate.
-
Use critical values to test the null hypothesis H0: 1 2 = 20 versus the alternative hypothesis H0: 1 2 20 by setting a equal to .10, .05, .01, and .001. How much evidence is there that the...
-
Assume that on December 31, 2013, The Coca-Cola Company borrows money from a consortium of banks by issuing a $900 million promissory note. The note matures in four years on December 31, 2017, and...
-
Nestle Group, a multinational food products firm based in Switzerland, recently issued its financial statements. The auditor's opinion attached to the financial statements stated the following: ''In...
-
On January 1, 2014, assume that Turner Construction Company agreed to construct an observatory for Dartmouth College for $120 million. Dartmouth College must pay $30 million upon signing and $30...
-
For coordinates \(\left(x^{1}, x^{2} ight)\) and metric \(g=\operatorname{diag}\left(g_{11}, g_{22} ight)\), the Gaussian curvature is For a sphere with coordinates defined in the following figure,...
-
Consider the holonomic basis defined in Box 26.1 . Using that the tangent vector for a curve can be written \(t=t^{\mu} e_{\mu}=\left(d x^{\mu} / d \lambda ight) e_{\mu}\), show that Thus, \(g_{\mu...
-
The Lie bracket of vector fields \(A\) and \(B\) is defined as their commutator, \([A, B]=\) \(A B-B A\). The Lie bracket of two basis vectors vanishes for a coordinate basis but not for a...
Study smarter with the SolutionInn App