Question

Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the...

Write a java netbeans program.

Project Two,

Super Bowl A text file named “SuperBowlWinners.txt” contains the names of the teams that won the Super Bowl from 1967 through 2019. Write a program that repeatedly allows a user to enter a team name and then displays the number of times and the years in which that team won the Super Bowl. If the team entered by the user has never won the Super Bowl, report that to the user instead. For example, when a user enters “Cowboys” as the team name, your program should search the list of team names for “Cowboys”, counting the number of times it was found. Your program should also display each of the years in which the specified team won the Super Bowl. For the Cowboys, the five years in which they won the Super Bowl were 1972, 1978, 1993, 1994, and 1996. Your program should allow the user to continue to make requests until they enter a suitable sentinel value such as the word “quit” or the letter “q” in place of a team name. This is an example of possible output: Super Bowl Winners This program will tell you how many times and in which years a football team won the Super Bowl. Enter a name of 'quit' to exit. Enter the team name: Browns The Browns have yet to win the Super Bowl. Enter the team name: Eagles The Eagles won the Super Bowl once in 2018. Enter the team name: Dolphins The Dolphins won the Super Bowl 2 times in 1973, and 1974. Enter the team name: Raiders The Raiders won the Super Bowl 3 times in 1977, 1981, and 1984. Enter the team name: quit Thank you. To receive full credit for this programming assignment, you must: • Use the correct file name. • Submit a program that executes correctly. • Interact effectively with the user.

Grading Guideline:

• Correctly name the file submitted. (5 points)

• Create a comment containing the student’s full name. (5 points)

• Document the program with other meaningful comments. (5 points)

• Store the team names correctly. (10 points)

• Store the Super Bowl years correctly. (10 points)

• Define and use a sentinel value correctly. (5 points)

• Prompt the user for a football team name. (5 points)

• Correctly count and display the number of Super Bowl wins. (20 points)

• Correctly display the year(s) for each Super Bowl win. (20 points)

• Use proper (different) formatting for year or years. (5 points)

• Use prompts that were easy to understand. (10 points)

Cowboys

Cowboys

49ers

Cowboys

Packers

Broncos

Broncos

Rams

Ravens

Patriots

Buccaneers

Patriots

Patriots

Steelers

Colts

Giants

Steelers

Saints

Packers

Giants

Ravens

'Seahawks

Patriots

Broncos

Patriots

Eagles

Patriots

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.

LINE 35 IN THE CODE: String filePath = "C:\\Users\\SAW\\Documents\\NetBeansProjects\\SuperBowl\\src\\superbowl\\SuperBowlWinners.txt";

UPDATE THE VARIABLE filePath with file path of SuperBowlWinners.txt

CODE

package superbowl;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

//class SuperBowl
public class SuperBowl {

    //main method
    public static void main(String args[]) {
        //Scanner object to read in input from user
        Scanner sc = new Scanner(System.in);

        System.out.println("Super Bowl Winners");
        System.out.println("This program will tell you how many times and in which years a football team won the Super Bowl. Enter a name of 'quit' to exit.");

        //loop to read user input and process the output until user enters "quit"
        while (true) {
            //variable to store user input team name
            String name;

            //array to store years that the team won Super Bowl
            int years[] = new int[100];

            //initializing year as 1967
            int year = 1967;

            //initializing count as 0
            int count = 0;

            //try block to open file and process
            try {
               //file path of SuperBowlWinners.txt, update the variable with file path of SuperBowlWinners.txt
                String filePath = "C:\\Users\\SAW\\Documents\\NetBeansProjects\\SuperBowl\\src\\superbowl\\SuperBowlWinners.txt";
              
                //opening file SuperBowlWinners.txt
                Scanner fileIn = new Scanner(new File(filePath));

                //prompt for team name
                System.out.print("Enter the team name: ");
                name = sc.next();

                //if name equals quit
                if (name.equals("quit")) {
                    System.out.println("Thank you.");
                    //exits the loop
                    break;
                }

                //loop repeat until end of file
                while (fileIn.hasNextLine()) {
                    //if a line equals team name
                    if (name.equals(fileIn.nextLine())) {
                        //appends year to array
                        years[count] = year;

                        //incrementing count
                        count++;
                    }
                    //incrementing year
                    year++;
                }
            } //catch block if file not exist
            catch (FileNotFoundException f) {
                System.out.println("File Not Found!");

                //exits the loop
                break;
            }
            //if count equals 0
            if (count == 0) {
                //prints output
                System.out.println("The " + name + " have yet to win the Super Bowl.");
            } //if count equals 1
            else if (count == 1) {
                //prints output with year which they won the Super Bowl
                System.out.println("The " + name + " won the Super Bowl once in " + years[0] + ".");
            } //if count greater than 1
            else {
                //prints name and count
                System.out.print("The " + name + " won the Super Bowl " + count + " times in ");

                //loop to print years which they won the Super Bowl
                for (int i = 0; i < count; i++) {
                    //if year is which they last won Super Bowl
                    if (i == count - 1) {
                        //prints year
                        System.out.println(" and " + years[i] + ".");
                    } //otherwise
                    else {
                        //prints year
                        System.out.print(years[i] + ", ");
                    }
                }
            }
        }
    }
}

INPUT FILE

on w Super BowlWinners.txt x Packers Packers Jets Chiefs Colts Cowboys Dolphins Dolphins Steelers lers Raiders Cowboys ers er38 39 40 पापा का पापा का Patriots Patriots Steelers Colts Giants Steelers Saints Packers Giants Ravens Seahawks Patriots Bron

OUTPUT

♡ Output - SuperBowl (run) x run: Super Bowl Winners This program will tell you how many times and in which years a football

CODE SCREEN SHOT

SuperBowl.java X package superbowl; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; //clM //file path of SuperBowlWinners.txt, update the variable with file path of SuperBowlWinners.txt String filePath = C:\\User10 101 //exits the loop break; NO LO NO LOCO O //if count equals 0 if (count == 0) { //prints output System.out.println(The

Add a comment
Know the answer?
Add Answer to:
Write a java netbeans program. Project Two, Super Bowl A text file named “SuperBowlWinners.txt” contains the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program in Java according to the following specifications: The program reads a text file...

    Write a program in Java according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "print" - prints the student records (first name, last name, grade). "sortfirst" - sorts the student records by first name. "sortlast" - sorts the student records by last name. "sortgrade" - sorts the...

  • Suppose you are a rabid football fan and you get into a discussion about the importance of offens...

    Suppose you are a rabid football fan and you get into a discussion about the importance of offense (yards made) versus defense (yards allowed) in terms of winning a game. You decide to look at football statistics to provide evidence of which variable is a stronger predictor of wins. Part a) Develop a simple linear regression that compares wins to yards made. Perform the following diagnostics on this regression: 1) test of significance on the slope; 2) assess the fit...

  • Suppose you are a rabid football fan and you get into a discussion about the importance of offens...

    Suppose you are a rabid football fan and you get into a discussion about the importance of offense (yards made) versus defense (yards allowed) in terms of winning a game. You decide to look at football statistics to provide evidence of which variable is a stronger predictor of wins. Can use the minitab. Part a) Develop a simple linear regression that compares wins to yards made (please show me the scatter plot) . Perform the following diagnostics on this regression:...

  • The excel file National Football League provides various data on professional football for one season.     Construct a scatter diagram for Points/Game and Yards/Game in the Excel file. Does there a...

    The excel file National Football League provides various data on professional football for one season.     Construct a scatter diagram for Points/Game and Yards/Game in the Excel file. Does there appear to be a linear relationship? Develop a regression model for predicting Points/Game as a function of Yards/Game. Explain the statistical significance of the model. Draw conclusions about the validity of the regression analysis assumptions from the residual plot and standard residuals. National Football League Data 2007 Season Team Points/Game Yards/Game...

  • The excel file National Football League provides various data on professional football for one season.     Construct...

    The excel file National Football League provides various data on professional football for one season.     Construct a scatter diagram for Points/Game and Yards/Game in the Excel file. Does there appear to be a linear relationship? Develop a regression model for predicting Points/Game as a function of Yards/Game. Explain the statistical significance of the model. Draw conclusions about the validity of the regression analysis assumptions from the residual plot and standard residuals. National Football League Data 2007 Season Team Points/Game Yards/Game...

  • Help with java . For this project, you will design and implement a program that analyzes...

    Help with java . For this project, you will design and implement a program that analyzes baby name popularities in data provided by the Social Security Administration. Every 10 years, the data gives the 1,000 most popular boy and girl names for kids born in the United States. The data can be boiled down to a single text file as shown below. On each line we have the name, followed by the rank of that name in 1900, 1910, 1920,...

  • Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that...

    Program 7 File Processing and Arrays (100 points) Overview: For this assignment, write a program that will process monthly sales data for a small company. The data will be used to calculate total sales for each month in a year. The monthly sales totals will be needed for later processing, so it will be stored in an array. Basic Logic for main() Note: all of the functions mentioned in this logic are described below. Declare an array of 12 float/doubles...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT