Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8492847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:50:34+00:00 2026-06-10T22:50:34+00:00

Here is an example output that I am looking for, for my program. Example

  • 0

Here is an example output that I am looking for, for my program.

Example Output

On each line enter a stadium name and the game revenue

Enter done when you are finished

Giants 1000

Foxboro 500

Giants 1500

done

Enter the name of a stadium to get the total revenue for:

Giants

The total revenue is 2500.00

I got everything working but the total revenue at the end. I’m not sure how to go into my linkedlist and grab the game revenue and display it.. This is my code right now, and what I have been messing with…

import java.util.LinkedList;
import java.util.Scanner;


public class LinkedLists {

    private final Scanner keyboard;



    private final LinkedList<String> stadiumNames;
    private final LinkedList<Integer> gameRevenue;


    public LinkedLists() {
        this.keyboard = new Scanner(System.in);
        this.stadiumNames = new LinkedList<String>();
        this.gameRevenue = new LinkedList<Integer>();
    }

    public void addData(String stadium, int revenue){
        stadiumNames.add(stadium);
        gameRevenue.add(revenue);
    }

    public void loadDataFromUser() {
        System.out.println("On each line enter the stadium name and game revenue.");
        System.out.println("Enter done when you are finished.");

        boolean done = false;
        while(!done) {
            System.out.print("Enter the name of the stadium:");
            String stadium = keyboard.next();
            if (stadium.equals("done")) {
                done = true;
            } else {
                System.out.print("Enter game revenue: ");
                addData(stadium, keyboard.nextInt());
            }
        }
    }

    // return -1 if not found
    public int getIndexForName(String name) {

        if(stadiumNames.contains(name)){
            System.out.println("The total revenue is: " +gameRevenue.get(0));
            System.exit(0);
        }

        return -1;

    }


    public void showInfoForName(String name) {
        int index = getIndexForName(name);
        if (index==-1) {
            System.out.println("There is no stadium named " + name);
        } else {

        }
    }

    public void showInfoForName() {
        System.out.println("Enter the name of the stadium to get the total revenue for it.");
        showInfoForName(keyboard.next());
    }

    public static void main(String[] args) {
        LinkedLists pgm = new LinkedLists();
        pgm.loadDataFromUser();
        pgm.showInfoForName();
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:50:35+00:00Added an answer on June 10, 2026 at 10:50 pm

    Try this:

    public int getIndexForName(String name) {
        if (stadiumNames.contains(name)) {
            int total = 0;
            for (int i = 0 ; i < stadiumNames.size() ; i++)
                if (stadiumNames.get(i).equals(name))
                    total += gameRevenue.get(i);
            System.out.println("The total revenue is: " + total);
            System.exit(0);
        }
        return -1;
    }
    

    There are better ways of doing this though. I would perhaps use a Map that maps each stadium name to its total revenue. You could update this map in the addData method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is an example that outputs 6 : public static void main(String[] args) {
I'm trying to generate svg-Code in a web-application. Here's an example output: <?xml version=1.0
For example Input <url wiki=https://wiki.archlinux.org/index.php/Main_Page forums=https://bbs.archlinux.org/> Desired output <url wiki=https://wiki.archlinux.org/index.php/Main_Page forums=https://bbs.archlinux.org/> Here's a sample
I was just looking at some example code and came across a line, I
I'm looking for a minimal viable example here. I've been googleing and reading up
I am looking to extract a string from a URL. Here is an example
Here an example http://jsfiddle.net/EhLsT/ $(window).scroll(function () { if ($(window).scrollTop() > $(#header).offset().top) { $(#floating).show(); }
Here is example which I have try <?php include 'spider/classes/simple_html_dom.php'; $html = new simple_html_dom();
Here an example http://jsfiddle.net/7aVXc/ Let' say current image height is 400px . How do
Here an example http://jsfiddle.net/NuzDj/ If you resize windows size, sidebar overlapping the wrapper &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.