Write a program that sorts prices of 10 tacos in ascending order based on the price, using arrays. I am trying to sort tacos. The user must enter the names of the 10 taco and the prices and I sort them in ascending order.
so far I have:
public class TacoSorter {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner keyboard = new Scanner(System.in);
System.out.println("Welcome to the taco price sorter! Enter 10 taco names and prices and I'll sort it!");
System.out.println("Enter the name of taco ");
Scanner input = new Scanner(System.in);
final int TotalTacos = 10;
double[]tacos = new double[TotalTacos];
for(int n =0; n < tacos.length; n++){
System.out.println("Enter a name of taco" + (n+1));
tacos[n] = input.nextInt();
System.out.println("Enter the price of the taco");
}
}
I want the result to be somewhat similar to elcome to the taco price sorter! Enter 10 taco names and prices and I'll sort it!
Enter the name of taco 1
Crunchy Taco
Enter taco's price
1.19
Enter the name of taco 2
Crunchy Taco Supreme
Enter taco's price
1.59
Enter the name of taco 3
Soft Taco
Enter taco's price
1.19
Enter the name of taco 4
Soft Taco Supreme
Enter taco's price
1.59
Enter the name of taco 5
Chicken Soft Taco
Enter taco's price
1.79
Enter the name of taco 6
Crispy Potato Soft Taco
Enter taco's price
0.99
Enter the name of taco 7
Double Decker Taco
Enter taco's price
1.89
Enter the name of taco 8
Double Decker Taco Supreme
Enter taco's price
2.29
Enter the name of taco 9
Doritos Locos Taco (Nacho Cheese)
Enter taco's price
1.49
Enter the name of taco 10
Doritos Locs Tacos(Fiery) Supreme
Enter taco's price
1.89
Sorted Tacos are
Taco Prices Crispy Potato Soft Taco 0.99
Taco Prices Crunchy Taco 1.19
Taco Prices Soft Taco 1.19
Taco Prices Doritos Locos Taco (Nacho Cheese) 1.49
Taco Prices Crunchy Taco Supreme 1.59
Taco Prices Soft Taco Supreme 1.59
Taco Prices Chicken Soft Taco 1.79
Taco Prices Double Decker Taco 1.89
Taco Prices Doritos Locs Tacos(Fiery) Supreme 1.89
Taco Prices Double Decker Taco Supreme 2.29
Finally: