Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSE 1321L: Programming and Problem Solving | Lab Assignment 5 - 100 points What students will learn: 1) Declaring arrays 2) Initializing arrays 1D
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 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.
Step by Step Solution
★★★★★
3.48 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started