Create a new project called Lab9 and copy the given .java files into the src folder of this lab project folder. Refresh the project in Eclipse to show the provided files there.

Exercise 1 - Iterative vs. recursive methods 1. Create a new project called Lab9 and copy the given .java files into the src folder of this lab project folder. Refresh the project in Eclipse to show the provided files there. 2. Open FibonacciDemo.java and FactorialDemo.java and examine the code. Carefully read through the ifib() and rfib() methods in FibonacciDemo and ifact() and rfact() in FactorialDemo. Compare the iterative and recursive approaches in both classes. Why do the iterative methods require so many variables? What are the base cases of the recursive methods? 3. Run the program and when asked for numbers, enter5,10,15, and 20 . Write down the running times reported by the algorithm. Experiment with other numbers too but note that Factorial will not work for numbers over 25 as the long type will not be able to hold numbers larger than that. 4. In FibonacciDemo, modify the code to include a new variable called methodCalls2 that keeps track of the number of calls made to methodrfib()when the value of the parameternis 2 and prints it out in the main() method. Run the program and enter the value 40 . How many calls are made torfib()when the value of the parametern=2? Write down this result. 5. Why is the recursive algorithm for computing Fibonacci numbers so slow compared to the iterative algorithm? Does the value of methodCalls2 make sense with this rationale?

Exercise 1 – Iterative vs. recursive methods 1. Create a new project called Lab9 and copy the given .java files into the src folder of this lab project folder. Refresh the project in Eclipse to show the provided files there. 2. Open FibonacciDemo.java and FactorialDemo.java and examine the code. Carefully read through the ifib() and rfib() methods in FibonacciDemo and ifact() and rfact() in FactorialDemo. Compare the iterative and recursive approaches in both classes. Why do the iterative method

Read More

(Characters around Circle) Write a program that displays a string “Welcome to Java” around the circle, as shown in Figure 14.44b (Book). Hint: You need to display each character in the right location with appropriate rotation using a loop.

(Characters around Circle) Write a program that displays a string "Welcome to Java" around the circle, as shown in Figure 14.44b (Book). Hint: You need to display each character in the right location with appropriate rotation using a loop. Sample output: Please submit the following: 1. The entire project folder containing your entire project ( That includes .java file) as a compressed file. (zip) 2. Program output−screenshot Also, 1. Copy and paste source code to this document underneath the line "your code and results/output " 2. Include screenshot or your running program Points will be issued on the following requirements: - Program Specifications / Correctness - Readability - Documentation - Code Efficiency - Meaningful variable names - Assignment Specifications Before submitting make sure that: - Did you submit required files? - Recheck if you have missed anything?

(Characters around Circle) Write a program that displays a string “Welcome to Java” around the circle, as shown in Figure 14.44b (Book). Hint: You need to display each character in the right location with appropriate rotation using a loop. Sample output: Please submit the following: 1. The entire project folder containing your entire project ( That includes .java file) as a compressed file. (zip) 2. Program output−screenshot Also, 1. Copy and paste source code to this document underneath the lin

Read More

Develop a program to simulate a mall consists of several stores, each store contains a group of items. Using the system you can add items to the shopping kart, remove them, edit their data, and confirm purchase according to the following rules:

Create a Java program A shopping lists. This could be done as a linked list of nodes where each node has its own child linked list of store options (Linked list of linked lists) as follows: Develop a program to simulate a mall consists of several stores, each store contains a group of items. Using the system you can add items to the shopping kart, remove them, edit their data, and confirm purchase according to the following rules: 1- Every store specializes in a specific type of items that is not found in any other store. 2- The item in each store is an object with the following attributes: a- Name: String b- Id: String c- Quantity: integer d- Price: integer e- StoreNumber: integer (store index in the Main list already defined based on the store type you decided) (The store number is according to your choice to arrange the stores in the original list (it is considered previously specified by you) 3- The addition of a new item the share should be ordered by name. 4- The deletion process will be performed based on the ID of the item. 5- The customer could search for any item in any store by entering the name and ID of that item, the system should display the store ID in which the item found and the available amount of that item. 6- Purchase process: a- Store cart: - The system should have a cart to store probable items to purchase (cart list). When adding an item to the cart list its quantity should be decreased from the store list based on the quantity ordered from the customer (for this task the quantity of the item should be checked). a- The items in the cart could be purchased or returned to the store. If the customer returned any item, it should be returned to the correct store, the items at that store should remain in the correct order, and the quantity of that item should be increased. b- Final step of the purchase process is to confirm the process. By confirming the purchase, items should be removed from the cart and the total price should be calculated and displayed to the customer. aThe whole system is shown in the following class diagram

Create a Java program A shopping lists. This could be done as a linked list of nodes where each node has its own child linked list of store options (Linked list of linked lists) as follows: Develop a program to simulate a mall consists of several stores, each store contains a group of items. Using the system you can add items to the shopping kart, remove them, edit their data, and confirm purchase according to the following rules: 1- Every store specializes in a specific type of items that is

Read More

For this lab, you will implement a simple To Do List application. The program must include a GUI that looks like this: ToDos must provide the following features: Adding items:

For this lab, you will implement a simple To Do List application. The program must include a GUI that looks like this: ToDos must provide the following features: Adding items: To add a new item: Click the "New Item" button, at which point all of the input fields clear Enter the following fields: Item - Required field - Cannot be blank - Must be unique -- there must not exist another item with this name Priority - Required field - Cannot be blank - Must be an integer > 0 - Items with a lower priority value have a higher priority. For example, an item with priority 1 has higher priority than an item with priority 5. Deadline - If checked, this item has a deadline, and the Month, Day, and Year drop-downs are enabled. If not checked, these drop-downs are disabled. - The Year drop-down shows years for the next 10 years (2022-2031) - The Day drop-down must always show the correct options based on the month and year selected. For example, if "January," it must show 1-31 days. If "June", it must show 1-30 days. If "February" in a leap year, it must show 1-29 days. If "February" in a non-leap year, it must show 1-28 days. Notes - Optional field, can be left blank - Scrollable text area Click the "Save Item" button - If any of the input is invalid, a warning dialog pops up, stating, "Invalid input!" - If all input is valid, a dialog pops up, stating, "Item saved!" The new item then appears in the list on the left, and it is selected. View item: To view an existing item, click on the name in the list, and that item's info will show up on the right. Edit item: To edit an existing item: - Select the item in the list - Edit any info in the field on the right - Click the "Save Item" button If any of the input is invalid, a warning dialog pops up, stating, "Invalid input!" - Take care of the case in which the user attempts to change an existing item's name to one that already exists in the list. This should not be allowed. - If all input is valid, a dialog pops up, stating, "Item saved!" Delete item: To delete an item: - Select the item in the list - Click the "Delete" button Toggle done: To mark an item as "done", click this button. It will cause the item to appear with strikethrough text in the list. Click the button again and it will mark the item as not done, and cause the strikethrough to disappear. Program exit: The program must exit through the "Exit" menu item in the "File" menu in the menu bar. Other Requirements/Details - The order in which ToDo items appear in list is determined based on the following: - It is first ordered by done/not done (all not done items come before all done items) - Then by priority (lower priority value comes before higher priority value) - Then by name lexicographically

For this lab, you will implement a simple To Do List application. The program must include a GUI that looks like this: ToDos must provide the following features: Adding items: To add a new item: Click the “New Item” button, at which point all of the input fields clear Enter the following fields: Item – Required field – Cannot be blank – Must be unique — there must not exist another item with this name Priority – Required field – Cannot be blank – Must be an integer > 0 – Items with a lower prio

Read More

In this lab assignment, you are asked to write java code of given classes in the following class diagram You are given an UML diagram that expresses relationship between three classes. Circle class is the parent class of the Curve and Cylinder classes.

In this lab assignment, you are asked to write java code of given classes in the following class diagram. You are given an UML diagram that expresses relationship between three classes. Circle class is the parent class of the Curve and Cylinder classes. Also, you are given Circle.java and testlnheritance.java files. Examine the given UML diagram and code. 1) Add variable definitions to the Circle class. Be careful about accessibility modifiers given in the UML 2) Implement the getArea method. The method will initially print the message: name of the class + "getArea method is invoked". Then, it will calculate and return the area of the circle by the formula area =πr2. Note: You can retrieve the name of the class by this.getClass(). getSimpleName(). 3) Implement Curve and Cylinder classes as given in the UML diagram. a. getArea method in the Curve and Cylinder class will initially print the message: name of the class + "getArea method is invoked". b. Then, it will calculate the area of the object and return it. c. Area formulation for cylinder: A=2πr(h+r) ( h stands for height) d. Area formulation for curve: A=(α/360)πr2 ( α stands for angle) e. draw method of Curve and Cylinder classes will initially call the parent class' draw method. Note: Your can access the method of the parent class by super.method() f. Then, it will print one of the following strings: "This method is overloaded with an double parameter the value is: " + val "This method is overloaded with an int parameter the value is: " + val 4) Complete the testinheritance class to produce the following output. Add calls to getArea and draw methods and print the calculated areas. Note: Do not forget to add variable definitions and implement getters and setters in all classes. Expected Output: Circle getarea method is invoked Circle area value is: 78.5 Cylinder getarea method is invoked Cylinder area value is: 351.68 Curve getarea method is invoked Curve area value is: 2.3549999999999995 Circle draw method is invoked cylinder draw method is invoked Cylinder draw method is invoked This method is overloaded with an int parameter the value is: 20 Curve draw method is invoked Curve draw method is invoked Curve draw method is invoked This method is overloaded with an double parameter the value is: 10.8

In this lab assignment, you are asked to write java code of given classes in the following class diagram. You are given an UML diagram that expresses relationship between three classes. Circle class is the parent class of the Curve and Cylinder classes. Also, you are given Circle.java and testlnheritance.java files. Examine the given UML diagram and code. 1) Add variable definitions to the Circle class. Be careful about accessibility modifiers given in the UML 2) Implement the getArea method.

Read More

Using best practises in programming, design and develop a project based on the following requirements: Ask the user how many words they would like to type

Directions: Using best practises in programming, design and develop a project based on the following requirements: 1. Ask the user how many words they would like to type 2. Let the user input the words 3. Print the words one by one with their respective frequencies 4. Ask the user if they want to repeat. If they say yes, repeat the steps. If not, end the program. • Assume the program only allows up to 20 words • The program may read the number of words and words all in the same line or separate lines Purpose: To demo the knowledge and use of loops and conditional statements, functions and array structures. To think and select the proper loop to accomplish different tasks. Throughout the program, pay attention to variable definitions, data types, initializations, and all other...

Directions: Using best practises in programming, design and develop a project based on the following requirements: 1. Ask the user how many words they would like to type 2. Let the user input the words 3. Print the words one by one with their respective frequencies 4. Ask the user if they want to repeat. If they say yes, repeat the steps. If not, end the program. • Assume the program only allows up to 20 words • The program may read the number of words and words all in the same line or separat

Read More

Upon running the program, it should welcome the user to your Ice Cream shop and assign them a random order number.

Directions: Using best practises in programming, design and develop a project based on the following requirements: 1. Upon running the program, it should welcome the user to your Ice Cream shop and assign them a random order number. (randomly generated by the system.) 2. Next, it should ask the user if they want ice cream on a cone or cup. 3. Ask them for the number of scoops. Limit the maximum number of scoops to three. 4. Ask them for the flavour of the ice cream for each scoop they selected. For the scope of this program, please limit the options to three. 5. Ask them if they want any toppings. For this program, please limit the possible toppings to three. 6. Come up with an algorithm to set prices based on the user's choices. 7. Recap the order. If the user confirms, thank them and display that the order was placed. 8. Based on user selected options display a total (with tax and tips). Display this summary including order number. 9. Ask the user if they want to place another order. If they say yes, repeat the steps. If not, end the program. Purpose: To demo the knowledge and use of loops and conditional statements. To think and select the proper loop to accomplish different tasks. Throughout the program, pay attention to variable definitions, data types, initializations, and all other good programming practices.

Directions: Using best practises in programming, design and develop a project based on the following requirements: 1. Upon running the program, it should welcome the user to your Ice Cream shop and assign them a random order number. (randomly generated by the system.) 2. Next, it should ask the user if they want ice cream on a cone or cup. 3. Ask them for the number of scoops. Limit the maximum number of scoops to three. 4. Ask them for the flavour of the ice cream for each scoop they selected.

Read More