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
-
Betsy Co is working on maintaining a steady dividend payout ratio over the years. Each year, for the last several years, Betsy Co has paid out 30% of its net income as dividends. The remaining funds...
-
Current Attempt in Progress The comparative balance sheets for Acme Company appear below: ACME COMPANY Comparative Balance Sheet Assets Dec. 31, 2025 Dec. 31, 2024 Cash Accounts receivable Inventory...
-
Draw and explain the following: 1. Proton to Proton Chain 2. CNO Cycle
-
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...
-
Assuming that the population is normally distributed, construct a 95% confidence interval estimate for the population mean for each of the following samples: Sample A: 1 1 1 1 8 8 8 8 Sample B: 1 2 3...
-
What might John have done differently in the early communications process to improve later performance review sessions?
-
Percentage of Credit Sales} Roeker Company provides information systems consultation services to large companies in the Chicagoland area. Due to a dip in the economy, Roeker has increased the...
-
Saddleback Company makes camping lanterns using a single production process. All direct materials are added at the beginning of the manufacturing process. Information for the month of March follows:...
-
7. Given f(x) = Vx2 + 3, determine p(x), q(x), and r(x) such that f (x) = p(q(r(x))). vv Part D - Application [APP - 20 marks] 1. Solve for x, where O S x ST. VVVV 1 tan x = - sin (2x) 2. The...
-
Describe your system for performance appraisal and training. How will you reward good employees? When you have weak employees how will you change their behavior?
-
To evaluate the derivative of tanh- (x), we invert the equation y = tanh- (2) to express a tanh(y). dx We then compute the derivative dy dy as a function of y. da However, we normally want to use the...
-
How does the process of cellular respiration in eukaryotic organisms differ from that of prokaryotes, and what role do organelles such as mitochondria play in this metabolic pathway ?
-
In cost accounting, what term refers to the process of assigning indirect costs to specific cost objects based on the proportional use of resources, activities, or drivers, allowing for more accurate...
-
1. Let random variables X and Y each have range (1,2,3,4). The following formula gives their joint probabilities P(X = i, Y =j) = (i+j)/80 Compute each of the following: (a) Find the joint and...
-
You are a newly employed Accountant at Harvey company Ltd. The company produces two products, X and Y. Within the first week of your arrival, you were presented with the following information by a...
-
What would be the account balance in the Cash account after the following transactions, assuming a zero beginning balance? Owner invested cash. $128,500 $33,300 Purchased supplies with cash. Received...
-
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...
-
\((n-1)!, n=12\) Evaluate the factorial expression for the given value of \(n\).
-
Hiroshi Mori began an upholstery cleaning business on October 1 and engaged in the following transactions during the month: Oct. 1 Began business by depositing $12,000 in a bank account in the name...
-
\(w ightarrow x ightarrow y ightarrow u ightarrow v ightarrow s ightarrow r ightarrow q ightarrow t ightarrow w\) Use the figure shown to find the weight of each Hamilton cycle. 13 3 S 1 7 2 4 6 t U...
Study smarter with the SolutionInn App