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
A Configuration Management System is a collection of formal documented procedures used to apply the following items EXCEPT:
RoseWind [281]

Answer: (C) Confirm project requirement

Explanation:

 The configuration management is the type of system and it is collection of the formal document that is use to applying for the technical direction. It is the subsystem of the management system of the project.

It basically record each change occur in the project and then report the each change status in the project. It also control various physical characteristics in the project.

It identify all the physical and the functional characteristics of any type of service, result and product in the project document. It basically include the tracking system that is used for the document authorizing and also for the controlling purpose.  

4 0
3 years ago
Random number between 0 and 5 (inclusive)
____ [38]

Answer:

3

why though???????

^_________^

7 0
3 years ago
Read 2 more answers
Are bops safe for organisations ? State your views on it
seropon [69]

Answer:

Explanation:

Crew members need to remember that blowout prevention equipment is heavy any very unforgiving. Working around BOPs (nippling up or down, ram replacement, etc.) puts workers in a high hazard area. All personnel involved in the operation must be fully alert and knowledgeable in their tasks. All crew members should participate in the Pre-Job Safety meeting. Communications are critical in this operation and all personnel should be aware of the signals to be used.

6 0
4 years ago
Your team at amazon is overseeing the design of a new high-efficiency data center at HQ2. A power grid need to be generated for
Alla [95]

Following are the python program to the given question:

from collections import defaultdict #import package

import heapq as h#import package

def primsMST(gr, st_v): # defining a method primsMST that takes two values in parameters  

   primalMST = defaultdict(set)#defining primalMST as a variable that calls defaultdict method  

   v = set([st_v])# defining a variable v that calls the set method and hold its value

   e_list = [(c, st_v, to)for to, c in gr[st_v].items()]#defining variable e_list that use loop to hold value in list

   h.heapify(e_list)# use package that holds heapify and holds its value

   while e_list:#defining while loop that checks e_list  

       c, s, e = h.heappop(e_list)#holding heapop method value in c,s,and e variable

       if e not in v:#defining if block checks e value is not in v

           v.add(e)# use add method to add value in v

           primalMST[s].add(e)#use primalMST as list that adds value in mwthod

   for nxt, c in gr[e].items():#defining for loop that uses nxt, and c variable that checks value in list

       if nxt not in v:#defining nxt variable that checks value is not in v

           h.heappush(e_list, (c, e, nxt))#add value into the heappush method

   return primalMST#return method value

connects=[['A','B',1],['B','C',4],['B','D',6],['D','E',5],['C','E',1]]#defining a list connects

my_gr=dict()#defining a variable my_gr that holds method dict() value  

for el in connects:#defining a for loop that uses el to count connects list value

   my_gr[el[0]]=dict()#use my_gr as list hold value in dict method

   my_gr[el[1]]=dict()#use my_gr as list hold value in dict method

for el in connects:#defining another for loop that uses el to count connects list

   my_gr[el[0]].update({el[1]:el[2]}) # use update method that update value in my_gr

   my_gr[el[1]].update({el[0]:el[2]})# use update method that update value in my_gr

x=dict(primsMST(my_gr, list(my_gr.keys())[0]))#defining x variable that calls dict method and  hold its value  

a=[]#defining an empty list

for k in x:#defining a for loop that uses k to hold dict method value

   for no in x[k]:#defining a loop that checks list value

       a.append([k,no,my_gr[k][no]])#use a that add value in list  

       print(a)#print list value.

Output:

Please find the attached file.

Program Explanation:

  • Import package.
  • defining a method primsMST that takes "gr and st_v" as parameters.
  • Inside the method, a primalMST as a variable is declared that calls "defaultdict" method.
  • Use the v variable that calls the set method and hold its value.
  • Defining "e_list" that uses the loop to hold value in lists, and define the heapify and holds its value.
  • In the next step, it defines a while loop checks e_list, and defines variable and hold value into the method and use another if to check value and return its value.
  • A list "connects" is declared that holds a value and defines a "my_gr" that holds "dict" method value and uses multiple for loop to print the calculated list value.

Learn more:

dictionary: brainly.in/question/14673591

List: brainly.in/question/25140412

7 0
3 years ago
In a wireless transmission data travels on invisible radio waves. true or false
vazorg [7]
<span>This is true. Radio frequency waves are not of high energy like visible light, and therefore, people cannot see them directly. They are made up of electromagnetic radiation, and their wavelengths in the electromagnetic spectrum are longer than infrared light.</span>
6 0
4 years ago
Other questions:
  • You must create an instructional video for your company and are required to ensure it is compatible with your company's windows
    6·1 answer
  • Analyze the following network traffic logs depicting communications between Computer1 and Computer2 on opposite sides of a route
    12·1 answer
  • Write a Bare Bones program that takes as input a value for X and places 4 times the value of X into the value of Z. The value of
    10·1 answer
  • Recall that when the built-in function open() is called to open a file for reading, but it doesn't exist, an exception is raised
    8·1 answer
  • Discuss the importance of top management commitment and the development of standards for successful project management. Provide
    10·1 answer
  • The Electronic Communications Privacy Act requires an investigator to have a wiretap order to acquire ___________ information fr
    8·1 answer
  • I'm trying the game WWE 2k20 for my computers and technology and a extra credit question is how do you pull down the singlet str
    12·1 answer
  • c) If you are at foreign country visit, which banking card would you prefer to keep with you during visit (Debit Card or Credit
    10·1 answer
  • Trees 1. 2. 3. 4. 5.​
    6·1 answer
  • Which popular tool is used in agile software development TCS?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!