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]
3 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]3 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
1. Here is a program segment to find the quantity base . Both base and exp are entered at the keyboard. System.out.println("Ente
zavuch27 [327]

Answer:

The correct code to this question can be de4fined as follows:

double power;

power = Math.pow(base, exp);

Explanation:

In the given question the choices were missing, that's why we defined the correct code only.

  • In the given code a two double variable "base and exp" is declared, that input the value from the user-side, and store its value into there respective variables.
  • In the next step, "power", that is a double variable is declared, which uses the  "Math.pow" function that calculates given values power and prints its value.

please find the attachment of the full code.

3 0
3 years ago
What tab would you choose to check your spelling in a document?
Degger [83]

The tab that you would use is review

8 0
3 years ago
Read 2 more answers
Which domain will redirect you to the amazon website?
Vinvika [58]

Answer:

Amazon.com

Explanation:

Every online business has a domain name that redirects to thier website usually has this format https:// of http:// followed by the domain name.

3 0
3 years ago
Mr. Cooper would like to customize his Excel software so his students can create an electronic graph in Excel for their lab repo
Neko [114]
The third one probably
5 0
3 years ago
____ formatting is automatically updated if you change data in the worksheet.
andriy [413]

Answer:

<u>Conditional</u> formatting is automatically updated if you change data in the worksheet.

Explanation:

Conditional formatting can be described as a tool that allows users to format a particular cell or a group of cells. The formatting also changes for any data being changed in the sheet.

A particular cell can have up to three format conditions and these conditions will be applied automatically to any changes entered in the cell. The conditional formatting also has the option to highlight the important cells.

4 0
3 years ago
Other questions:
  • Which of these is a subdirectory? <br> HTTPS <br> /FAQ <br> .org <br> WWW
    15·1 answer
  • When you create a new slide in a presentation program, you are promoted to choose a placeholder. True or false?
    11·2 answers
  • Why might a peer-to-peer network not be the best choice for a large corporate office setting?
    14·1 answer
  • Which type of malware can hijack internal windows components and often goes undetected because it is already loaded when the ant
    14·1 answer
  • type of weapon of mass decruction taht spreads deadly radioactive material by way of conventinal explosion
    15·1 answer
  • Which environment variable affects the number of past commands used in the current shell session?
    14·1 answer
  • Which term collectively describes hard disks, CDs, and flash drives?
    11·2 answers
  • Bob has 2 candy bars he is fat what hapennes
    5·2 answers
  • What is the meaning of photography​
    5·2 answers
  • What should students hope to get out of classroom discussions? Check all that apply.
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!