CSC 210.03 Assignment 1 to 9 solutions

$180.00

Original Work ?

Download Details:

  • Name: CSC210Asmts-jwfddg.zip
  • Type: zip
  • Size: 4.01 MB

Category: You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

CSC 210.03 Assignment 1 Simple Java Programs

ABOUT THIS PROJECT

You will be creating simple Java programs. By the end of this assignment, you should understand how to create simple Java programs

❐Part 1: BODY MASS INDEX (BMI) Calculator[9 points]

INSTRUCTIONS Body mass index (BMI) is an estimate of whether a person is overweight. (See for example https://www.halls.md/bodymass-index/bmi.htm .) BMI is defined as 703 * (weight in pounds) / (height in inches)2 . A BMI of 25 is considered borderline overweight. Write a Java program that performs these actions: – Prompt the user to enter height in feet and inches (both integers) – Read the height in two separate prompts. For example if someone is 6 feet 7 inches, then 1. Ask the user to enter their feet part of their height as an integer, first, so : 6 2. Then, ask the user to enter their inches part of their height as an integer, second, so for example: 7 – Prompt the user to enter their weight in pounds (a double) – Calculate the BMI of the user (a double) – Display the BMI NOTE : Please do not use “Integer” class, use “int” FILE NAME REQUIREMENTS BMI.Java SUBMISSION INSTRUCTIONS 1. Submit the 1 BMI.Java file directly on iLearn 2. Take a screenshot of the output of your program and paste it here CSC Note: BMI and weight outputs are rounded to 2 decimal points (.2f) Example

TIPS FOR PART 2 AND PART 3:

1. Save your user’s input in a variable in order to use it in the next printout When you use the Scanner object, don’t forget to save it in a variable like this To save an integer/a number: int myInt = myScanObj.nextInt(); //save user’s number input into an integer primitive variable named myInt To save a string: or String myString = myScanObj.nextLine();/save user’s string input into a String reference variable named myString. And yes, that is a “String” data type, with a capital “S” Why do you want to do this? So that you can print out what the user had entered.

For example: System.out.println(“You entered this” + myInt); or System.out.println(“You entered this” + myString); 2. If you will not be using the user’s input for an output later on, then you don’t need to scan it at all. “scan” means this myScanObj.nextInt(); or myScanObj.nextLine(); 3. The KnockKnock joke is a very simplistic program It is a very simplistic program, so if the user answers anything at all, it will still proceed as if the user entered a correct answer. Meaning you could expect a conversation like this: Knock Knock? ←-your program’s output

XXXBLBBLABs;isdfa98f0s <—- user input, no need to save or scan this Annie <– ignores user input, and goes on with your program output joke XXX…!!ososd9 ← user’s input, no need to save or scan this XXX…!!ososd9 thing you can do I can do better <— you take this last user’s input and add to your response output ” you can do I can do better”

❐Part 2: Knock Knock Joke [8 points] Knock Knock Joke: In the future assignment, you can make a more fun knock knock joke program. For now, it would work for only 1 joke and 1 exact response you may like the best. 😊 Ideally, users are expected to enter the proper response as shown in the green font. And your program responses with 1 joke.

SUCCESSFUL RUN REQUIREMENTS 1. Running the program should output a statement like the above FILE NAME REQUIREMENTS KnockKnock.Java

SUBMISSION INSTRUCTIONS 1. Submit the 1 KnockKnock.Java file directly on iLearn 2. Take a screenshot of your Knock Knock Joke and paste it here. It can be any Knock Knock joke that takes in a user input and outputs a response C S C 2 1 0 . 0 3 A S SIG N M E N T 1 F A L L 2 0 2 0

❐Part 3: Your own idea [11 points] It can be similar to part 1 or 2. Please use what you learned from problem 1 and 2 and write a simple code to make it work. a. It must provide a welcome printout “Welcome to my program called: … “ (2 points) b. Must include prompting reading user input ex. “Please enter this value… “ (2 points) c. And, must use this input for the next step printout. It can be completely funny or serious, or maybe a project you have been thinking on. (2 points)

d. Must provide an explanation of your idea, and what it is trying to do as I showed in 1 and 2. ex. “This program is to calculate blablabla…” (2 points) FILE NAME REQUIREMENTS .Java SUBMISSION INSTRUCTIONS 1. Submit the 1 .Java file directly on iLearn 2. Take a screenshot of the output of your program and paste it here

Explanation: This program is a math mini-game. The pseudocode is as follows: ● ask user for an integer (e.g., 5), ● ask user for the squared value of the integer provided in part 1 (e.g., 25), ● evaluate the answer, ● print a message to tell the user if that was correct. Note: the program does not perform any checks on the input and will crash if an integer is not provided in either parts. Example 1: If the user provides a correct answer to their question Example 2: If the user provides an incorrect answer to their question

❐Part 4: Comment your code [2 points] Every Java file you write in this assignment will require you to include descriptive comments. In this assignment, you are tasked with writing a descriptive 1. Headers 2. Comments You can write comments in two ways: • Single-line comments using the // notation. • Multi-line comments using the /* and */ notation. a. Include a proper header at the top of every Java file. Figure 1 Header Format /* * Assignment * Description: * Name: * ID: * Class: CSC 210-

* Semester: */ Replace each tag (such as ) with the appropriate text. You should adhere to this format as closely as possible. You do not need to include the <> symbols in your header fields. b. Only if you work with a Study Buddy, include your Buddy’s name in your header at the top of every Java file. Figure 1 Header Format /* * Assignment * Description: * Name: * Teammate: * ID: * Class:
* Semester: */ Replace each tag (such as ) with the appropriate text. You should adhere to this format as closely as possible. You do not need to include the <> symbols in your header fields. Figure 1 b. Place your comments at the top of each Statement, however you don’t need to comment print (i.e. anything that starts with System.out.print…) statements. An example of commenting codes is included below in Figure 2: Figure 2 
❐Part 5: Reflection 200 words [18 points] *Points will be deducted for less than 200 words. Please put what was helpful and what was not helpful in working on this program. And also please tell me how you would improve your own program from part 3, if you were given more time. Only if you work with a Study Buddy, write down how your buddy helped you, i.e. Don helped me learn a new technique for understanding OOP, by thinking about containers. Place your reflection in this Google Form The reflection below is identical to the one submitted via Google Forms. The instructions given in the assignment were quite clear.

CSC 210.03 Assignment 2 Selections

ABOUT THIS PROJECT

You will be creating a program that will process the scores that a student receives during a driving exam. You will not be creating the driving exam itself. The program is intended to process the scores after the exam has been completed. Program Input: ● The program will ask for the student’s ID number, the written exam score, and the practical exam score. Program Output: ● Then, the overall score will be calculated using a specific formula designed below. ● Once the overall score is computed, the program will let the user know whether or not they passed.

❐Part 1: Driving Exam Evaluator [28 points]

In this project, you will be creating a program that will process the scores that a student receives during a driving exam. You will not be creating the driving exam itself. The program is intended to process the scores after the exam has been completed. The program will ask for the student’s ID number, the written exam score, and the practical exam score. Then, the overall score will be calculated using a specific formula designed below. Once the overall score is computed, the program will let the user know whether or not they passed.

FILE NAME REQUIREMENTS Java file name: DrivingExamEvaluator.java Main class name: DrivingExamEvaluator INSTRUCTIONS 1.Collect the information Your first task is to collect the following information from the user: • The student’s ID number, as a String. The program should validate the input to ensure that it does not exceed 9 characters. If it does, then the program should ignore the user input and automatically set the ID number as a “default” variable integer number, which you declared and assign the value “999999999”;

• The written exam score. See the paragraph below for required validation. • The practical exam score. See the paragraph below for required validation. For both the written exam score and practical exam score, the minimum possible value is 0 and the maximum possible value is 500. For both of these scores, if the user attempts to enter a value that is less than 0, then the program should ignore user input and set the score as 0. If the user attempts to enter a value that is greater than 500, then the program should ignore user input and set the score as 500.

NOTE: This means, that you will have to re-assign the scores to either 0 or 500. Also please print out what the user’s final scores are for both written and practice, AND when you have re-written it so the user know that they provide an invalid score and you had to modify it to stay within the valid values of 0 and 500. 2.Compute the overall score The next step is to calculate the overall score. You do this by taking into account the following weights: • The written exam score makes up 74 percent of the overall score.

• The practical exam score makes up 26 percent of the overall score. You will need to calculate the overall score based on the two scores and their respective weights.

3.Display the summary Finally, you will be displaying the results of the exam to the user. The following results should be displayed: • The student’s ID number. • The written exam score (in terms of percentage). • The practical exam score (in terms of percentage). • The overall score (in terms of percentage).

• A message telling the student if they passed or failed the exam. In order to pass the exam, the student’s overall score must be at least 52 percent of the raw maximum score of 500. If the student does not satisfy this requirement, then that means they fail the exam. The program should be finished once this information is displayed. It is up to you to decide how you would like the information to be displayed. The only requirement is that you present the exact values that are requested above, and the summary must be easy for the user to understand. Aside from that, you can be creative with the design and arrangement of the summary. Output Passing

Output NON Passing

SUBMISSION INSTRUCTIONS

1. Submit the 1 DrivingExamEvaluator.java file directly on iLearn 2. Take a screenshot of the output of your program for passing and non passing and paste it here Output for passing :

Output for not passing :

❐Part 2: Your own idea [10 points] It can be similar to part 1. Please use what you learned from Selections. a. In Assignment 1, Part 3: Your own idea, you created your own idea of a program. For this assignment, you must improve upon your first program by adding what you learned from Selections b. Must include Selections of 2 or more different conditions, using “if”, “else if”, or “if” and “else” c. (Optional) you can use “switch” c. And, must output different results based on the selection to the user d. Must provide an explanation of your idea, and what it is trying to do as I showed in 1 and 2. ex. “This program is to calculate blablabla…” (2 points) FILE NAME REQUIREMENTS .Java

SUBMISSION INSTRUCTIONS 1. Submit the 1 .Java file directly on iLearn 2. Take a screenshot of the output of your program run for all conditions and paste it here Explanation: This is a number guessing game. The execution loop is as follows: 1. The program generates a pseudorandom integer between a certain range (1–100 inclusive, by default). 2. Asks the user for a guess between (1–100 by default). 3. The program checks if the user has selected the correct number by checking the difference between the target number and the user’s guess. The user is given a hint, if: ○ delta > 0, then the number is too high ○ delta < 0, then the number is too low 4. The loop (step 2–3) continues until the user has correctly guessed the number (delta = 0) or

when they have run out of attempts (10, by default). Note: the program does not perform any checks on the input and will crash if an integer is not provided in any part. Example 1: When the user guesses the correct number before they run out of guesses (win) Example 2 and 3 are on the following page.

Example 2: When the user runs out of guesses; fails to guess the right number (loss) Example 3: When the user guesses the correct answer on the last guess (win)

❐Part 3: Comment your code [2 points] Every Java file you write in this assignment will require you to include descriptive comments. In this assignment, you are tasked with writing a descriptive 1. Headers 2. Comments You can write comments in two ways: • Single-line comments using the // notation. • Multi-line comments using the /* and */ notation. a. Include a proper header at the top of every Java file. Figure 1 Header Format /* * Assignment * Description: * Name: * ID: * Class: CSC 210-

* Semester: */ Replace each tag (such as ) with the appropriate text.
You should adhere to this format as closely as possible. You do not need to include the <> symbols in your header fields. b. Only if you work with a Study Buddy, include your Buddy’s name in your header at the top of every Java file. Figure 1 Header Format /* * Assignment * Description: * Name: * Teammate: * ID: * Class: CSC 210-

* Semester: */ Replace each tag (such as ) with the appropriate text. You should adhere to this format as closely as possible. You do not need to include the <> symbols in your header fields. Figure 1
b. Place your comments at the top of each Statement, however you don’t need to comment print (i.e. anything that starts with System.out.print…) statements. An example of commenting codes is included below in Figure 2: Figure 2
❐Part 4: Reflection 50 words [8 points] *Points will be deducted for less than 50 words. Please put what was helpful and what was not helpful in working on this program.
And also please tell me how you would improve your own program from part 3, if you were given more time. Only if you work with a Study Buddy, write down how your buddy helped you, i.e. Don helped me learn a new technique for understanding OOP, by thinking about containers.

CSC 210.03 Assignment 3 BODY MASS INDEX (BMI) COMPUTATION PRO

 ❐Part 1: BMI History Pro [18 points]

1. Prompt our user to enter his/her height in feet and inches (two integers). 2. Prompt our user to enter his/her lowest weight in pounds (an integer). 3. Prompt our user to enter his/her heaviest weight in pounds (an integer). 4. Print a table of Body Mass Index (BMI) for the height entered: a) Weights range from the low weight to the high weight, at increments of 5 pounds.

▪ This means to get more than 1 line low weight and high weight should have more than 5 pounds of difference ▪ To get additional decimals behind decimal point, you may want to cast one of the variables into a float or a double ▪ prompt user twice int user2 = scan.nextInt()// feet ▪ int user3 = scan.nextInt()// inches ▪ 703 * weight( height * height) // height is in inches Math.pow(heigh, 2) b) Each row of the table lists ▪ The value of WEIGHT (an integer), followed by spaces, then ▪ The value of BMI to four decimal places (a float), followed by spaces, then

▪ The CONDITION whether overweight (BMI > 25), or not overweight (BMI <= 25). 5. Document our code carefully. Our program output must be identical to the sample output (except author name). OUTPUT OF SAMPLE RUN FOR PART 1

for (… System.out.print(“^”); } System.out.print(“^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^”); SUBMISSION INSTRUCTIONS 1. Submit the 1 TableBmi.java file directly on iLearn 2. Take a screenshot of the output of your program and paste it here Output :

❐Part 2: BMI Code Reuse [10 points]

1. So far, we have written 2 versions of the BMI program, BMI Standard version from assignment 1 and BMI History Pro version from this Assignment 2, part 1. Reusing the programs, please make our BMI offer users to choose which version they want to use. (After users make their choice, they should be able to use the program they chose.) 2. Document our code carefully using the provided guidelines. Include screenshots and notes in our report. OUTPUT OF SAMPLE RUNS FOR PART 2

1. Submit the 1 TableBmiPro.java file directly on iLearn 2. Take a screenshot of the output of your program for option 1 and option 2 and paste it here

Output for Option 1 :

Output for Option 2:

❐Part 3: Your own idea [10 points]

It can be similar to part 1 or 2. Please use what you learned from Loops. a. In Assignment 1, Part 3 and in Assignment 2, Part 2: Your own idea, you created your own idea of a program. For this assignment, you must improve upon your first program by adding what you learned from Loops b. Must include Loops, using either “for”, or “while” or “do while” c. And, must use the loop to output more than 1 line of result d. Must provide an explanation to the user of your idea “This program will help you… ” (2 points) FILE NAME REQUIREMENTS .Java

SUBMISSION INSTRUCTIONS

1. Submit the 1 .Java file directly on iLearn 2. Take a screenshot of the output of your program run for all conditions and paste it here Explanation: This program calculates the compound interest rate and displays the generated interests and the cumulative balances as a table. The execution loop is as follows: ● The user enters the required parameters to calculate the periodic compounding interest. These are: ○ the principal deposit amount, ○ the compounding frequency, ○ the nominal annual interest rate, and ○ the deposit term.

● The program prints and re-summarizes these parameters to the user. ● The program will determine whether to display a yearly or a quarterly report. This depends on the deposit term length. ● These parameters are then used to calculate the interests generated and subsequently, the new balance for each period.

○ These results are printed in each row. Each row will present the following information: ■ the deposit length, ■ the interest generated at that period, ■ the cumulative interest generated, ■ and the new principal balance at that period ○ Depending on the deposit term length, the number of rows may vary. For example: ■ a yearly report for a six-year term deposit will output seven rows, one row for each year, with the first row at year 0 ■ a quarterly report for a two-year deposit will output nine rows, one row for each quarter, with the first row at year 0

● After the table is displayed, the user is then presented with a summary, presenting: ○ their original principal sum (what they started with) ○ the total generated interest (how much they made) ○ and their final balance (the total at the end) There are infinite possible outcomes for this program. However, there are two main ways the output may differ: the report may be on a quarterly or yearly basis. The program will generate a quarterly report if the deposit term is 2 years or less (a yearly report for a oneor two-year deposit would be pretty useless).

Otherwise, it will generate a yearly report. Note on output formatting ● “Year 0” ○ The table starts at year 0 deliberately in order to illustrate the starting point of the deposit. This is meant to contrast the starting interest and how it increases over the period. ● Deposit length column decimal years ○ The years are formatted to contain two decimal points for quarterly reports. ● Rounding ○ All dollar amounts are rounded to the nearest cent. The two example cases are on the following pages.

Example 1: The user inputs a deposit term that is twelve years. The program will output a yearly report displaying the interests and principal balance at the end of each period.

Example 2: The user inputs a deposit term that is two years. The program will output a quarterly report displaying the interests and principal balance at the end of each period. What a rate!

❐Part 4: Comment your code [2 points]

Every Java file you write in this assignment will require you to include descriptive comments. In this assignment, you are tasked with writing a descriptive 1. Headers 2. Comments You can write comments in two ways: • Single-line comments using the // notation. • Multi-line comments using the /* and */ notation. a. Include a proper header at the top of every Java file. Figure 1 Header Format /* * Assignment * Description: * Name: * ID: * Class: CSC 210-

* Semester: */ Replace each tag (such as ) with the appropriate text. 
You should adhere to this format as closely as possible. You do not need to include the <> symbols in your header fields. b. Only if you work with a Study Buddy, include your Buddy’s name in your header at the top of every Java file. Figure 1 Header Format /* * Assignment * Description: * Name: * Teammate: * ID: * Class: CSC 210-

* Semester: */ Replace each tag (such as ) with the appropriate text. You should adhere to this format as closely as possible. You do not need to include the <> symbols in your header fields. Figure 1 
b. Place your comments at the top of each Statement, however you don’t need to comment print (i.e. anything that starts with System.out.print…) statements. An example of commenting codes is included below in Figure 2: Figure 2 

❐Part 5: Reflection 50 words [8 points]

*Points will be deducted for less than 50 words. Please put what was helpful and what was not helpful in working on this program. And also please tell me how you would improve your own program from part 3, if you were given more time. Only if you work with a Study Buddy, write down how your buddy helped you, i.e. Don helped me learn a new technique for understanding OOP, by thinking about containers.
Place your reflection in this Google Form The reflection below is identical to the one submitted on Google Forms.

CSC 210.03 Assignment 4 BODY MASS INDEX (BMI) COMPUTATION PRO

 ❐Part 1: BMI Using Methods [15 points]

1. Please do/redo the Part 2 of Assignment 03 using at least 2 methods. ● Name our methods bmiStd and bmiPro. ● bmiStd behaves like the standard version of our BMI.java program and bmiPro behaves like the TableBMI.java version 2. Our program must produce an identical output as that of Assignment 03 Part 1 for Pro version, and Assignment 01 for Standard version OUTPUT OF SAMPLE RUN FROM ASSIGNMENT 1 OUTPUT OF SAMPLE RUN FROM ASSIGNMENT 3 PART 1

SUBMISSION INSTRUCTIONS 1. Submit the 1 BmiMethods.java file directly on iLearn 2. Take a screenshot of both outputs of your program and paste it here Output of Standard Version :

Output of Pro Version :

❐Part 2: Tracking the Value of a Dice [15 points]

Please write a Java program to track the count of each face of a dice as the user chooses to throw the dice several times. You may use this Java file as a starting point, download and please edit this file to complete our program. We are given 1 dice , with 6 face values : 1, 2, 3, 4, 5, and 6. Your task will be to create a program that will 1. Prompt the user for a number of throws, anywhere between 1 and 1 million times.

● You can assume the user will not enter anything more than 10_000_000 for this assignment ● We don’t a negative value or a very high number ● We want to use a Sentinel value. For my example I have used the integer 0 2. Unless the user enters a Sentinel value, of your choosing, you will continue to prompt the user for another number of throws

3. Outputs of Valid and Other outputs should look exactly like the below example Example output: of 10000 throws EAch of the output represent the count for when each face is selected first loop/ throw 0,0,0,0,0,0 // dice face 1, 2, 3, 4, 5, 6 0,1,0,0,0,0// count1, count2, count3…. 156, 135, 125 , 145, 100 = what is the average Take that average/ divided by total throws ==1/6

Print out will be 1. Print each count ,

2. Print each dice face Invalid value and Sentinel value output The Objective of this assignment is to A. Learn how to build a fully functional program, which validates users, by using methods, loops, selections, and data types B. To prove that, after a large amount of the dice throw, you do see the proof of the mathematical probability of each face of the dice as ⅙ for each face

SUBMISSION INSTRUCTIONS 1. Submit the 1 Dice.java file directly on iLearn 2. Take a screenshot of the output of your program showing the valid output and the average probability of each face as ⅙ and the output with sentinel and invalid values (negative and bigger than 1 million; If you test with too big a value you may run into errors, just test with 10 million or less)

0 Valid Output :

Invalid and Sentinel Output :

❐Part 3: Reflect with a Buddy 50 words [15 points]

1. Find your buddy. Look at the Study Buddy sheet and pair up with your assigned buddy. Or find someone to partner this task with. 2. You can set up a Slack, Discord, or a Zoom with your buddy to asynchronously or synchronously talk about anything, and also reflect on what was helpful and not helpful in completing this homework.

3. Each student will need to create 1 post to mark this assignment as complete. Have fun with this one!! 👋 Assignment 4

CSC 210.03 Assignment 5 COFFEE SHOP ACCOUNTING OPERATIONS

 ❐Part 1: CoffeeShopAccount [25 points]

File Name: CoffeeShopAccount.java Problem Description: You are an owner of a small coffee shop and you want to keep tabs of your shop’s balance, money in, money out and have a very light security using 4 digit PIN. Write a program to perform the following operations: 1. Check balance: This operation should display total losses or profit available, can be negative or positive

2. Money in: This operation should pay down any debt or add to the profit 3. Money out: This operation should subtract the amount from the available balance 4. Set or change a 4 digit PIN number: This operation should change the 4 digit pin number 5. Exit: Terminate the program execution Functional requirements: User shall be able to : 1. Choose from the menu what action to perform 2. Add money into the balance, and see their ending balance. Can be positive/ negative

3. Extract money from the balance, and see their ending balance. Can be positive/ negative. 4. Set up a 4-digit PIN 5. Exit immediately when the option to exit is chosen Tips: 1. All the methods are mainly updating the main Balance, except the update PIN method.

Balance therefore will be a value that needs to be access by all methods, therefore it needs to be passed into the method as a parameter 2. You can use System.out.print(“ with \n “); to format your menus and use System.out.printf(“… to print out your $ dollar amount using 2 decimals after decimal point .2f and %n for a new line”, value);

3. Create your program using the following best practice: First: // Type out the steps to creating your program, be specific in what needs to be global, or local, and inside or outside the loop Second: Create your code as if you don’t have any methods. Test that it is working first before creating methods. Third: Copy and paste your code from main into your various methods. Test that it is still working as expected. 4. Variables, we will consider them global, to declare in the main method: balance, pin, which can be accessed by all the methods.

5. Analyzing values: 1. Ask the user to enter the PIN and display the available balance only when the answer is correct.

use equals method to compare String: Syntax: s1.equals(s2) here s1 and s2 are String variables 2. Or use == method to compare PIN that is an integer int1 == int2 2. Withdraw balance only when the withdrawal amount is less than or equal to balance.

Rules & Guidelines:

1. You may assume the user will always enter the correct dollar in double format and menu in integer format 2. If the user enters any other number not in the menu, simply print a message that it is invalid and loop through the menu agaijavan. 3. Create at least 4 methods 4. Use a switch case to call the method that performs the operation. • E.g. If the user enters 1 to check balance then call that method 5. Create any additional methods you like

6. Name your methods as camelCased, and action-oriented, i.e. actionValue, getBalance, setBalance, spendBalance, etc. 7. Use while loop to display the bank operations and terminate the loop on Exit (i.e. operation 5) 8. Variables to declare in the main method: balance, pin

Case of wrong PIN entered: Example: Please paste your screenshot for this scenario here: Output :

0 Correct values entered: Please paste your screenshot for this scenario here: Output :

Changing PIN number Please paste your screenshot for this scenario here: Output :

Invalid Menu option output: Please paste your screenshot for this scenario here: Output :

Not enough money in the balance to spend output: Please paste your screenshot for this scenario here: Output :

SUBMISSION INSTRUCTIONS 1. Submit the 1 CoffeeShopAccount.java file directly on iLearn

❐Part 2: Reflect with a Buddy 50 words [13 points]

1. Find your buddy. Look at the Study Buddy sheet and pair up with your assigned buddy. Or find someone to partner this task with. 2. You can set up a Slack, Discord, or a Zoom with your buddy to asynchronously or synchronously talk about anything, and also reflect on what was helpful and not helpful in completing this homework.

3. Each student will need to create 1 post to mark this assignment as complete. Have fun with this one!! 👋 Assignment 5

CSC 210.03 Assignment 6 COFFEE SHOP ACCOUNTING OPERATIONS

❐Part 1: CoffeeShopInventoryManager [10 points]

File Name: CoffeeShopInventoryManager.java 1. (Total 10 points) Declare and create 3 arrays. a. (2 points) The first array, named items, should contain 5 items (“cups”, “coffee beans”, “lids”, “towel”, “sleeves”). Use Array-Initializer notation for assigning these 5 values to this array.

b. (3 points) The second array, named quantity, should contain the current quantity for each of the corresponding items. Obtain these quantities from the user. For each user input check if it is a valid number (greater than or equal to 0). See output below:

c. (3 points) The third array, named price, should contain the price per piece of the corresponding item (example, 4 dollars for a cups, 0.5 dollars for a coffee beans). Obtain these prices from the user. For each user input check if it is a valid number (greater than or equal to 0). See output below: d. (2 points. 1 per array) Use the appropriate datatype for each array.

Please paste your screenshot for this scenario here: Output :

❐Part 2: CoffeeShopInventoryManager [20 points]

2. (Total 20 points) A typical user of this program is the inventory manager. a. (3 points) Display to the user the possible operations on the inventory and prompt her/him to choose one. There are 5 possible operations: Print Inventory, Check for low inventory, Total inventory value, Highest and lowest inventory value items, Exit. The details of each of these operations are given below.

b. (3 points) Print inventory (p): This operation prints the inventory in the following format: Item Name, Quantity, Price Per Piece, Item Total Value. The last column prints the product of quantity and price per piece for each item. Go back to step a. Please paste your screenshot for this scenario here: Output :

c. (5 points) Check for low inventory (c): This operation checks for items that have 5 or fewer quantity, and prints them in the same format as in option(b). If there is no such item then print an appropriate message. Finally, go back to step a. Please paste your screenshot for this scenario here: Output :

d. (5 points) Highest and lowest inventory value items (h): This operation finds the item with the highest inventory value (quantity*price-per-piece), If there is more than one item with the same highest (or lowest) value then display all such items. Finally, go back to step a. Please paste your screenshot for this scenario here: Output :

e. (3 points) This operation computes the grand total value of the current inventory using the quantity and price per piece information, and prints that grand total value. Finally, go back to step a. Please paste your screenshot for this scenario here: Output :

f. (1 point) Exit (e): Exits the program. Please paste your screenshot for this scenario here: Output :

SUBMISSION INSTRUCTIONS 1. Submit the 1 CoffeeShopInventoryManager.java file directly on iLearn

❐Part 3: Reflect with a Buddy 50 words [8 points]

1. Find your buddy. Look at the Study Buddy sheet and pair up with your assigned buddy. Or find someone to partner this task with. 2. You can set up a Slack, Discord, or a Zoom with your buddy to asynchronously or synchronously talk about anything, and also reflect on what was helpful and not helpful in completing this homework. 3. Each student will need to create 1 post to mark this assignment as complete. Have fun with this one!!

CSC 210.03 Assignment 7 COFFEE SHOP ACCOUNTING OPERATIONS

 ❐Part 1: CoffeeShopInventoryManagerNew [10 points]

File Name: CoffeeShopInventoryManagerNew.java 1. (Total 10 points) Refactor previous CoffeeShopInventoryManager.java and combine 2 arrays into 1-2D array and keep your first array “items” a. (1 points) You should already have the first array “items” should contain 5 items {“cups”, “coffee beans”, “lids”, “towel”, “sleeves”}. Use Array-Initializer notation for assigning these 5 values to this array.

b. (2 points) Create a 1D array “labels” for each row, first element of the array is “quantity”, and second is “price”. c. (4 points) Initialize the secondary array, a 2D array, with length of “items” and “labels”. Do not hardcode the amount of row and columns of the 2D array – points will be taken off for hardcoded array row and column lengths. int[][] my2D arr = new int [2][5] -> new int [items.length][labels.length]This second array, named “values” its first row, should contain quantity for each of the corresponding elements in “items”.

The second row should contain the price per piece of the corresponding “items“. Obtain these quantities and prices from the user in one loop. Check if it is a valid number (greater than or equal to 0).

labels = {quantity, price}; for int i =0 items.length for intj =0 label.length temp = scan.nextInt(); do if temp <0 /print out enter value bigger than 0 else myArr[][] = temp while(temp < 0) System.println(label[i]) // row 0 ,print quantity, row 1 print price items[index for items] d. (3 points) Use all arrays in one loop to output a helpful message to the user, prompting entry into each row label and each item name, for each entry into the 2D array. See output below:

Please paste your screenshot for this scenario here: Output :

❐Part 2: CoffeeShopInventoryManagerNew [17 points]

2. (Total 17 points) A typical user of this program is the inventory manager. Refactor your previous CoffeeShopInventoryManager file such that this new file has at least 6 methods a. (2 points) 1st method: “getMenu”. Display to the user the possible operations on the inventory and prompt her/him to choose one. There are 6 possible operations: Print Inventory, Check for low inventory, Total inventory value, Highest and lowest inventory value items, Ordering More Inventory, and Exit. – Use a switch case to direct the program to call the other methods.

The details of each of these operations are given below. – If the user enters an invalid menu option please prompt them to input the correct numbers Please paste your screenshot for this invalid scenario here: Output :

b. (3 points)2nd method: “printInventory”. This operation prints the inventory in the following format: Item Name, Quantity, Value then Item Name, Price , Value.. Go back to step a. Please paste your screenshot for this scenario here: Output :

c. (3 points) 3rd method: “checkInventory”: This operation checks for items that have 5 or fewer quantity, and prints them in the same format as in option(b). If there is no such item then print an appropriate message. Finally, go back to step a. Please paste your screenshot for this scenario here: Output :

d. (3 points) 4th method: “minMaxInventory” This operation finds the item with the highest inventory value (quantity*price-per-piece), If there is more than one item with the same highest (or lowest) value then display all such items. Finally, go back to step a. Please paste your screenshot for this scenario here: Output :

e. (2 points) 5th method: “getTotal”. This operation computes the grand total value of the current inventory using the quantity and price per piece information, and prints that grand total value. Finally, go back to step a. Please paste your screenshot for this scenario here: Output :

f. (3 points) 6th method: “orderInventory”. This operation displays the menu of items and asks the user to enter the number they would like to order. This operation also updates the main value 2D array quantity chosen and returns an array to the main method, which updates the original array. Finally, go back to step a. For example if a towel was chosen to add quantity of 12, then the next printout towel value has been updated. See towel item below was 35 and now it is 47.

Please paste your screenshot for this scenario here: Output : Before After g. (1 point) Exit (e): Exits the program.

Please paste your screenshot for this scenario here: Output :

❐Part 3: Reflect 50 words [8 points] Let’s reflect on what we’ve learned so far.

 

❐Part 4 Optional Extra Credit : Ask and Answer [3 e.c

points] Ask or Answer a question posted in this form 👋 Assignment 7 Part 4: Ask and Answer

CSC 210.03 Assignment 8 PRACTICE WITH OBJECTS

❐Part 1: RectangleTest Class [8 points]

File Name: RectangleTest.Java 1. (The Rectangle class) Following the example of the Circle class in slides, design a class named Rectangle to represent a rectangle. This class contains: a. Two double data fields named width and height that specify the width and height of the rectangle.

The default values are 1 for both width and height. b. A no-arg constructor that creates a default rectangle. c. A constructor that creates a rectangle with the specified width and height. d. A method named getArea() that returns the area of this rectangle. e. A method named getPerimeter() that returns the perimeter. * Assignment * Description: * Name: * Teammate: * ID: * Class: CSC 210-

* Semester: */ 
2. Implement the above class. Write a test program RectangleTest.java that creates two Rectangle objects—one with width 4 and height 40 and the other with width 3.5 and height 35.9. Display the width, height, area, and perimeter of each rectangle in this. Note: Rectangle class should be in this same class order. (10 points) Sample output: There was no box here… I’m assuming you want a screenshot of the output here?

❐Part 2: Employee Class [8 points]

File Name: EmployeeTest.Java 1. (The Employee class) Design a class named Employee. This class contains: a. A string data field named employeeId for the employee’s id b. A string data field named name for employee’s name c. A string data field named email for email d. A int data field named deptId for the department id e. A constructor with no parameter f. A constructor that creates an employee with the specified employeeId, name, email, and deptId.
Use the same variable names and assign it to the clas data field using the keyword “this” g. Create getters and setters for each variable: i). Create setter methods named setEmployeeName() that sets the employee’s name, setEmployeeId() that sets the employeeId, setEmployeeEmail() that sets the employee email and setEmployeeDeptId() that sets the department ID. ii). Create getter methods modeled like above i.e. getEmployeeName, getEmployeeId, etc. for all the variables and return the values 2. Implement the above class.
Write a EmployeeTest.Java test program that creates an Employee object with your name as name, and employeeId is initialized with your student ID, your student email as email, and 210 for department ID. Print out this initial profile by using the getter methods. Then use setEmployeeDeptId() method, to change the department ID to 220. Print this new profile with the getter method for Employee Department Id. Example output 
Please paste your screenshot for this scenario here: Output :

❐Part 3: CoffeeShopEmployee Class [14 points]

File Name: CoffeeShopEmployee.Java Steps to follow for main method
1. Prompt the user to create 3 or more Employee objects from the Employee class, no parameter is needed 2. Use a loop and an Array of to create these objects and assign them as each element in the array 3. Use a loop to set the name, email, employee id, department Id properties of each objects, for all 4 variables values using setter methods of each object.
3. Create a method to print each Employee object in the Objects Array. Print out all employee details. Please paste your screenshot for this scenario here: Output :

❐Part 4: Reflect 50 words [5 points]

Let’s reflect on what we’ve learned so far. The following reflection is identical to the one posted on iLearn. This assignment was generally simple and straightforward. There were a couple of ambiguities on where each class needed to be defined and which files to submit. But was later clarified with a mentor on Slack. The requirement of separately instantiating the Employee object and using setters to provide value seemed a bit confusing and redundant. One could simply instantiate Employee with the constructor that was created as part of an earlier section, and then add that to the array. If the purpose was to make use of the setter, the prompt could’ve asked the user to tweak a particular employee after it has been set up.
👋 Assignment 8 Part 4: Your own Reflection
❐Part 5 Optional Extra Credit : Ask and Answer [3 e.c points] Ask or Answer a question posted in this form 👋 Assignment 8 Part 5: Ask and Answer

CSC 210.03 Assignment 9 PRACTICE WITH OBJECTS & INHERITANCE

❐Part 1: VirtualPet and VirtualPetTester Classes [20 points]

Guidelines for this Assignment: 1. The required name for the package is “virtualPet” package 2. The required name for the main Java file is VirtualPetTester.Java ● It should have a main method ● It should have at most 20 lines of code 3.

The required name for the 2nd Java file is VirtualPet.Java 4. The required name for the 3rd Java file is VirtualPlant.Java that inherits from the VirtualPet.java Triple check to make sure these requirements are included. If they are not, your submission will be considered invalid and will need to be corrected before being graded.

1. VirtualPetTester.java What should your VirtualPetTester.java file look like? ● It should have a main method ● It should have at most 20 lines of code This is a requirement and I will reduce points if there are more than 20 lines of code in the main. Use loops, arrays, or methods we have learned in class. I emphasize practicing this important skill so you understand what is efficient and inefficient code. As a developer this will help your manager and team enjoy working with you more and as a non-developer you can help design/spot inefficient code so that maintaining the program takes less time in the long run.

The VirtualPetTester.java Program class contains the main method, and contains the user experience for your program. */

The user experience should be the following: 1. The program should ask the user how many pets they want to create and name them. Think of a method to take care of this first setup. ● a. With this number you will create an array to hold the VirtualPet objects. Meaning if the user enters 3, you will use a loop to create an array type VirtualPet that will be initialized with empty VirtualPet objects. Hint: you will need to use an empty constructor in your VirtualPet class to do this.

● b. Validate the user entry, it should be a number larger than 0. If the user enters a smaller number then loop until the user enters a number larger than 0 ● c. Then ask the user to enter a name for each of their pets. You will need to loop through your Array of VirtualPet Objects and for each element in the Array, set the name for the VirtualPet object.

Hint: you can either create VirtualPet object with empty array and set name using setName() setter method in your VirtualPet class, or you can directly use the VirtualPet constructor with parameter name to initialize the objects in the array with names. See below instructions for the VirtualPet class. 2. And then provide the following menu options: 1. Check statuses 2. Feed your virtual pet 3. Play with your virtual pet 4. End program 3. Have the user enter their choice as an integer.

Depending on their choice, the following should happen. (1. Check statuses) — Create a method that will display the current values of happiness and energy in regards to their virtual pet. This method will call the printStatus method from VirtualPet.java. In VirtualPet.java class: ● a.Create a plainStatus method in your VirtualPet.java class that builds and returns the string to print Energy and Happiness levels. Use getters for this.

● b. Create a printStatus method in your VirtualPet.java class that does not return anything but prints the plain status method. In VirtualPlant.java class:

● Create a printStatus method that overrides printStatus in your VirtualPet.java class that does not return anything but uses super to call the parent plainStatus method and adds to it Plant Type. i.e. printStatus should print Energy: 35 Happiness: 35 Plant Type: orchid (2. Feed your virtual pet) — Create a method that will simulate the experience of feeding the virtual pet and do the following ● a. Call the method feed.

Luckily for you, should already be built into the VirtualPet class as an instance method. ● b. Print status for each object. You can also reuse the same method from check status to print status for each object. ● Since you can create various pets in the array, whenever you call the method feed(), it will feed all the pets in the array (3. Play with your virtual pet) — Create a method that will simulate the experience of playing with the virtual pet and do the following: ● a. Call the method play. Same thing as the 2nd option:

You already have this built into the VirtualPet class! ● b. Print status for each object. You can also reuse the same method from check status to print status for each object. ● Since you can create various pets in the array, whenever you call the method play(), it will play all the pets in the array (4. End program) — This will discontinue any other interactions with the virtual pet. Before the program ends, you should display a short summary of how well the user took care of their pet depending on the happiness status.

You should user selections statements (if-else) to determine how to summarize this experience. For example, if happiness is high, then you might want to say that the user did a good job! Or maybe happiness is low, so you might want to tell them that they should take care of their pet better. 4. If the user did not choose to end the program (Option 4), then they should be taken back to Step 2, where they will again be provided with the menu of possible actions to choose from. This cycle should repeat until the user decided to exit the program.

HINT: Use loops to make this happen! 2. VirtualPet.java Your base class needs the following:

I. Three instance variables: name — A string variable representing the pet’s name. happiness — An integer variable representing the pet’s happiness. The value should range from 1-100. energy — An integer variable representing the pet’s energy. This value should range from 1-100. II. Constructors: It needs two public constructors. They should initialize happiness and energy at 25. One constructor should have a single parameter: A String parameter to set the name instance variable. Remember, you have to make sure the name has a length of less than 30 characters.

How can you do this without rewriting your validation code? Hint: You can create additional methods. One constructor should have no parameters. This constructor should simply set the name as DEFAULT, but you should use the this keyword to make sure you are not writing duplicate code. If you are not sure what this means, see the slides near the end of Chapter 9. II. Public setter and getter methods: a. VirtualPet needs to have setter and getter methods for the name instance variable. The setter method should validate input, meaning it should only set the name if the new name is less than 30 characters. If the validation fails, you don’t have to set a default value for the name, but you can if you want to. b.

There needs to be a setter and getter for happiness. You do not need to provide validation in the setter method for happiness. c. There needs to be a setter and getter for energy. You do not need to provide validation in the setter method for energy. III. Additional public instance methods so that the user can manage their Virtual Pet Additional public instance methods so that the user can interact with their virtual pet. These methods should not return a value, and they shouldn’t have any parameters. Both methods below will have an effect on happiness and/or energy.

Additionally, both methods will have restrictions. If the virtual pet is restricted from performing the task, then there should be no effect on the pet’s happiness or energy. feed — A method that simulates the experience of feeding the pet. When called, this method should use setter methods to ● increase happiness by 5.

● increase energy by 30. RESTRICTION: You shouldn’t be able to feed your pet if energy is 80 or higher. This means that if energy is greater than or equal to 80, then calling feed() should have no effect on happiness or energy. play — A method that simulates the experience of playing with the pet. When called, this method should use setter methods to ● increase happiness by 20. ● decrease energy by 15.

RESTRICTION: You shouldn’t be able to play with the pet if their energy is 30 or lower. This means that if energy is lower than or equal to 30, then calling play() should have no effect on happiness or energy. Sample output: Enter number of pets and name output Enter # 1 output Enter #2, #3 output

Exit output In VirtualPet.java class: ● a.Create a plainStatus method in your VirtualPet.java class that builds and returns the string to print Energy and Happiness levels. Use getters for this. ● b. Create a printStatus method in your VirtualPet.java class that does not return anything but prints the plain status method.

❐Part 2: Child Class [10 points]

File Name: VirtualPlant.Java 1. The VirtualPlant class inherits from VirtualPet. This class contains: a. A string data field plantType for plant’s type, i.e. “orchid”, or “succulent”, etc.

b. A constructor that inherits from the parent class with the parameter name. Inherit from this parent class constructor, use “super” to initialize the name, and add a new parameter plantType that is initialized in this constructor for ex: VirtualPlant(String name, String plantType){ super(name); this.plantType = plantType }

c. Create getters and setters for the unique child variable: plantType d. Override (see Chapter 11 notes for reminder of syntax) the parent method printStatus. In this method, use super.plainStatus to inherit the method that returns the plainStatus string and concatenate it to form another string with Plant Type string and value. Then use this string to print out Energy, Happiness, and the Plant type. Use getters for plantType value.

2. Implement the above class. Refactor your VirtualPetTester.java file to include an if/else statement. This control statement will ask the user to enter the number “1” to create new Virtual Pets or “2” to create new Virtual Plants. a. Use overloading to simplify your code, we covered this in lectures on Chapter 6 Methods, and on the last lecture Chapter 11 Inheritance. Here’s an example of what my methods look like in VirtualPetTester, note that there are duplicates of methods, with different parameter types == overloading.

b. If the user chooses “1” use the existing menu you’ve created for Virtual Pet. Hint: You might want to create a method “menu” with different parameters, one for type VirtualPet[] and one for type VirtualPlant[], see overloading tip in a. c. If the use chooses “2” use the overloaded menu you should create for Virtual Plant and will contain VirtualPlant[] array which will contain VirtualPlant objects d. Test your code for both.

You should be able to see the difference in the print outs for Pets vs Plants, i.e. the Plants will have plant types. Example output Note on overloading It turns out that overloading a lot of the methods in the test class were not needed. The only significant change that was needed was the invocation of the different constructors depending on the type of pet the user chooses to create.

Since VirtualPlant is a child of VirtualPet, instances of either class can be stored in the same VirtualPlant array. This means that overloading the methods in the test class that relies on the array as a parameter was not necessary. Note that the only difference between the two classes is the addition of the field “plantType” in the child, VirtualPlant, and the plainStatus method in the child class has already been overloaded.

Output of ● if/else 1 or 2 for Virtual Pet and Virtual Plants ● quantity of Plants and naming Plants ● Plant Menu display ● option #1

Output for Options #2,#3, and #4

❐Part 4: Reflect 50 words [5 points]