1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Andre45 [30]
4 years ago
9

Write a program that lets the user enter the name of a team and then displays the number of times that team has won the World Se

ries. The WorldSeriesWinners.txt file contains a chronological list of the world series winning the World Series in the time period from 1903 to 2018. Tips and tricks: Question. How do I use arrays to complete this assignment? Answer 1: You can use arrays if you want. You will need read the file twice, first time to determine the number of lines in the file, and then the second time to assign values to the elements of your array. You will have to create this string array with the size that you found out by reading the file the first time. Answer 2. Do not use arrays, use ArrayList class instead. The topic is covered in Chapter 7 of your text book. We will cover the material during the next lecture, but there is nothing that prevents you from using this class.
Computers and Technology
1 answer:
xz_007 [3.2K]4 years ago
5 0

Answer:

see explaination

Explanation:

import java.io.*;

import java.util.Scanner;

public class Winners {

public static void main(String args[]) throws IOException {

Scanner sc = new Scanner(new File("WorldSeriesWinners.txt"));

String commands[] = new String[100000];

int c = 0;

while (sc.hasNextLine()) {

String input = sc.nextLine();

System.out.println(input);

if (input.isEmpty())

continue;

commands[c++] = input;

}

sc.close();

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter the name of a team: ");

String name = keyboard.nextLine();

int count = 0;

for (int i = 0; i < c; i++) {

if (commands[i] != null) {

if (commands[i].equals(name)) {

++count;

}

}

}

if(count!=0)

System.out.println(name + " has won the World Series in the time period from 1903 through 2018 " +count + " number of times" );

else

System.out.println("Team with name "+name+ " does not exists");

}

}

You might be interested in
Which file types have .exe and .png as their extensions?
uysha [10]
.png are for photos and .exe are for programs.
6 0
3 years ago
Read 2 more answers
Write a new method in the Rectangle class to test if a Point falls within the rectangle. For this exercise, assume that a rectan
algol [13]

Answer:

Explanation:

The Rectangle and Point class is not provided in this question but was found online. Using that code as guidance I created the following method named contains. This method takes in a Point object and checks to see if the x-axis point is inside the parameters of the Rectangle class and then checks the same for the y-axis. If it is inside the Rectangle then the method returns true otherwise it returns false.

def contains(self, point):

       return self.width > point.x >= self.corner.x and self.height > point.y >= self.corner.y

7 0
3 years ago
Among the second generation home console companies,which managed to come out on top
crimeas [40]

Answer:

The second generation of home consoles occurred from (1976-1988) at this time the most popular and consoled regarded as best was the Atari 2600

Explanation:

answer from Cligon768 on this site

3 0
4 years ago
Operation code field is present in:
Tasya [4]
The answer is most likely C
6 0
3 years ago
Which statement is true about the elements of the interface of a presentation program? A. The status bar appears at the top of t
Ivan

Answer:

C. Rulers indicate the margins, tabs, and indents in a presentation slide.

Explanation:

6 0
4 years ago
Read 2 more answers
Other questions:
  • What is the correct method to use Dreamweaver to find broken links and orphaned files?
    15·1 answer
  • Which hypervisor works on older pcs without hardware virtualization support?
    9·2 answers
  • Which of the following statements is true?
    5·1 answer
  • One factor in algorithm performance that we've not had a chance to speak much about this quarter, but one that is certainly rele
    6·1 answer
  • DOUBLE POINTS!! PLEASE HELP QUICKLY!!!!!
    15·2 answers
  • Which practice is the safest way to sit at a desk while typing on the computer?
    12·1 answer
  • Detrmine whether the following pairs of lines are paralles , perpendialor or neither. 8x+9y=5 and 4x+2y=7 Y=2x-4 and y=4x-2 X=9
    15·1 answer
  • 16
    10·1 answer
  • Computer programming 5
    10·1 answer
  • Limited time only for christmas give yourself free 100 points YES YES yes yes yes
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!