Write and submit the source code for the following program. The program will use an integer array of size 10 to store the prices of smartphones. It will then determine and print the prices of the most expensive and cheapest phones. Use the following variables: int prices = new int; // Array of smartphone prices Assignment 1) Ask the user for the price of each smartphone (using a for loop) // this loop should print the prices horizontally mines prints vertically just like the sample output? 2) Sort the list of smartphones (once) from low to high price using the following statement: Arrays.sort(prices); 3) Print the three most expensive phones in order of decreasing price using the sorted array and a for loop 4) Print the three cheapest phones in order of increasing price using the sorted array and another for loop As always use the package name edu.cscc and include a comment with your name, the date, and the purpose of the program. Sample Output Enter all smartphone prices: 1100 1080 900 1200 900 700 550 800 400 250 Three Most Expensive Phones 1200 1100 1080 Three Cheapest Phones 250 400 550 Process finished with exit code 0
Can anyone help me with this? I cannot get the problems to print horizontally on the print line.
You must be signed in to leave a comment
17 October 2019, 20:22
what task is this?
17 September 2019, 00:43