(Java) - You are required to add comments to your code showing the different stages
Posted: Sat Nov 27, 2021 2:28 pm
(Java)
- You are required to add comments to your code showing the
different stages
Q1 ( 2.5 Marks ) Write a Java program to convert and display the contents of a two-dimensional array. The array data type must be integer. The array has the following data: arrayInteger = {{0, 1, 0},{1, 1, 0}} The program should search through the array and do the followings: 1. when it finds 0, then it should display " NO it is wrong", 2. When it finds 1, then it should display " YES it is right ". " The program must display the statements associated with each element, keeping in mind the output format should be two dimensional similar to that of the original array. Q2 ( 2.5 marks ) Write a java program to create prices of Shopping Cart items that provides a menu: 1: Create a new price for each item in the Cart list 2: Print the price of a particular item 0: Exit Enter your choice: The program should do the followings: 1. Define an array of size 10 elements: Shopping Cart which stores prices of items. 2. Define another array of size 10 elements: ItemsNames of the same size that stores names of items. 3. Create a method that displays the menu to give the user the possibility to use the menu as much as he/she wants 4. When the user select option 1, a. the program call a method that creates a new price for each item in the array. b. In the method you need to use random numbers between 1 and 1000 AED exclusive. 5. When user select option 2, a. the program call a method that prints the name of the requested item and its price. PS: Use do.....while loop along with switch statement to choose the appropriate menu options, and to allow the user to repeat the process.
- You are required to add comments to your code showing the
different stages
Q1 ( 2.5 Marks ) Write a Java program to convert and display the contents of a two-dimensional array. The array data type must be integer. The array has the following data: arrayInteger = {{0, 1, 0},{1, 1, 0}} The program should search through the array and do the followings: 1. when it finds 0, then it should display " NO it is wrong", 2. When it finds 1, then it should display " YES it is right ". " The program must display the statements associated with each element, keeping in mind the output format should be two dimensional similar to that of the original array. Q2 ( 2.5 marks ) Write a java program to create prices of Shopping Cart items that provides a menu: 1: Create a new price for each item in the Cart list 2: Print the price of a particular item 0: Exit Enter your choice: The program should do the followings: 1. Define an array of size 10 elements: Shopping Cart which stores prices of items. 2. Define another array of size 10 elements: ItemsNames of the same size that stores names of items. 3. Create a method that displays the menu to give the user the possibility to use the menu as much as he/she wants 4. When the user select option 1, a. the program call a method that creates a new price for each item in the array. b. In the method you need to use random numbers between 1 and 1000 AED exclusive. 5. When user select option 2, a. the program call a method that prints the name of the requested item and its price. PS: Use do.....while loop along with switch statement to choose the appropriate menu options, and to allow the user to repeat the process.