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
Write the contrapositive of each of the following statements. Healthy plant growth follows from sufficient water. Increased avai
rusak2 [61]

Answer:

Healthy plant growth follows from sufficient water.

Contrapositive: If water is insufficient, then there isn't healthy plant growth

Increased availability of information is a necessary condition for further technological advances

Contrapositive: Absence of further technological advances implies decreased availability of information.

Errors were introduced only if there was a modification of the program.

Contrapositive: If there wasn't any modification of the program then error was not introduced into the program

Fuel savings implies good insulation or storm windows throughout.

Contrapositive: The absence of good insulation or storm windows throughout implies that there is no fuel savings.

Explanation:

A contrapositive statement is formed from a conditional statement as we can see from the answers above.

In a contrapositive statement, we just interchange the hypothesis and the conclusion of the inverse statement.

This implies that, when the converse of the statement is true, then the inverse of the statement is also logically true.

5 0
2 years ago
Why we use cluster computing and hadoop framework for big data sysetm​
Ber [7]

Answer:

Explanation:

Hadoop clusters can boost the processing speed of many big data analytics jobs, given their ability to break down large computational tasks into smaller tasks that can be run in a parallel, distributed fashion.

5 0
2 years ago
Rubbing two sticks together to make a fire is an example what
Jet001 [13]
Rubbing two sticks together will cause friction
7 0
3 years ago
Read 2 more answers
Assume that x is a double variable that has been initialized. Write a statement that prints it out, guaranteed to have a decimal
Feliz [49]

Answer:

cout <<showpoint << x; is  the statement which  prints the decimal point,        but without forcing scientific.

Explanation:

The showpoint function in c++ print the decimal point number without forcing scientific.The showpoint function set  the showpoint format flag for the str stream in c++.

Following are the program in c++

#include<iostream> //header file

using namespace std; // namespace

int main() // main function

{

   double x=90.67; // double variable

   cout <<showpoint << x; // display x  without forcing scientific

  return 0;

}

Output

90.6700

6 0
3 years ago
What is the data rate of a DS0 signal?
djyliett [7]

Answer: 64 Kbps

Explanation:

3 0
2 years ago
Other questions:
  • Binary code what does this mean I was sick so I don't under stand
    7·2 answers
  • The cold war actually helped in the development of the internet true or false
    8·1 answer
  • Who are the four main antagonists in fnaf 1
    13·2 answers
  • Does anyone know the answers?
    8·1 answer
  • Write a program name Dollars that calculates and displays the conversion of an entered number of dollars into currency denominat
    11·1 answer
  • what you can do to increase your chances of getting employed with changes to your current digital footprint​
    6·1 answer
  • Why are mobile apps often easier to develop than desktop apps?
    11·1 answer
  • Write an algorithm to display your name 10 times​
    5·1 answer
  • Which type of computer is used to process large amount of data​
    15·2 answers
  • Match the feature to its function.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!