Write a program Start by reading the same 5 lines into 2 parallel arrays. Next,
ID: 3602982 • Letter: W
Question
Write a program Start by reading the same 5 lines into 2 parallel arrays. Next, prompt the user for a name. Search for that person in your string array. Use the index to access the parallel integer array and print out how many tickets that person sold. Then sort the array of names (using a selection sort) and print out the sorted list of names.
Sample Run #1: (the highlighted text is what the user types)
Enter Name Tickets? Joe 5000
Enter Name Tickets? Sue 4000
Enter Name Tickets? Bill 6000
Enter Name Tickets? Mary 2500
Enter Name Tickets? Bob 1800
Search for? Bill
Bill sold 6000 tickets.
The following people have sold tickets:
Bill
Bob
Joe
Mary
Sue
Explanation / Answer
import java.io.*;
import java.util.Scanner;
public class Morse
{
public static void main(String [] args) throws IOException
{
File file = new File("Morse.txt");
Scanner input = new Scanner(file);
String sentence;
char[] characters = new char[36];
String[] symbols = new String[36];
for(int i = 0; i < characters.length; i++)
{
for(int j = 0; j < symbols.length; j++)
{
char characs = input.nextLine().charAt(0);
String syms = input.nextLine();
characters[i] = characs;
symbols[i] = syms;
System.out.print(characters[i] + " " + symbols[i] + " ");
}
}
}
}
d its returning this
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.