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 8639841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T11:07:21+00:00 2026-06-12T11:07:21+00:00

Develop a top-down design and write a program to produce a bar chart of

  • 0

Develop a top-down design and write a program to produce a bar chart of gourmet-popcorn production for a cooperative farm group on a farm-by-farm basis.

  • The input to the program is a series of data sets, one per line, with
    each set representing the production for one farm.
  • Each data set consists of the name of a farm. Followed by a comma and
    one or more spaces, a decimal number representing acres planted, one
    or more spaces, and an integer representing the number of pint jars
    of popcorn produced for that farm.
  • The output is a bar chart that identifies each farm and displays its
    production in pints of corn per acre.
  • The output is a single line for each farm, with the name of the farm
    starting in the first column on a line and the bar chart starting in
    column 30. Each mark in the bar chart represents 25 pint jars of
    popcorn per acre.
  • The production goal for the year is 500 jars per acre. A vertical bar
    should appear in the chart for farms with production that does not
    meet this goal, and a special mark is used for farms with production
    greater than or equal to 500 jars per acre.

For example, given the input file

Orville’s Acres, 114.8 43801
Hoffman’s Hills, 77.2 36229
Jiffy Quick Farm, 89.4 24812
Jolly Good Plantation, 183.2 104570
Organically Grown Inc., 45.5 14683

the output would be:

Popcorn Co-op
Production in Hundreds
of Pint Jars per Acre
Farm Name 1 2 3 4 5 6
---|---|---|---|---|---|
Orville's Acres *************** |
Hoffman's Hills ****************** |
Jiffy Quick Farm *********** |
Jolly Good Plantation *******************#**
Organically Grown Inc. ************ |

This is the code I have already it runs and prints the correct format but it has an exception error. I am trying to split a string up into the farm name then a double acres and finally a int jars. The input file is

Orville’s Acres, 114.8  43801
Hoffman’s Hills, 77.2  36229
Jiffy Quick Farm,       89.4  24812
Jolly Good Plantation,  183.2  104570
Organically Grown Inc., 45.5        14683

The reason for all the spaces is I want it just to read lines with data.

Here is my source code

import java.util.Scanner;
import java.io.*;

public class Popcorn
{

public static void main(String args[])throws Exception
{

    printHeading(); 

    System.out.print("Input file name you want to read from: ");

    Scanner in = new Scanner(System.in);    

    String fileName = in.next();    //declares fileName a string that uses in as input

    Scanner input = new Scanner(new FileReader(fileName));  //Declares input as the fileName and reads the file in

    int jars;
    double acres;
    String amount;
    String farmName;
    System.out.println();
    System.out.println("\t\t\tPopcorn Co-op");
    System.out.println();
    System.out.println("\t\t\t\tProduction in Hundreds");
    System.out.println("\t\t\t\tof Pint Jars per Acre");
    System.out.println("Farm Name\t\t\t   1   2   3   4   5   6");
    System.out.println("\t\t\t\t---|---|---|---|---|---|");


    while (input.hasNextLine())
    {


        String inputLine = input.nextLine();    

        if (inputLine.isEmpty())
        {   

        }
        else 
        {
            farmName = inputLine.substring(0,inputLine.indexOf(','));
            String inputLine2 =  inputLine.substring(inputLine.indexOf(','),inputLine.length());
            Scanner line = new Scanner(inputLine2);
            acres = line.nextDouble();
            jars = line.nextInt();
            System.out.println(farmName + jars + acres);

        }

    }
}

private static void printHeading(){


    System.out.println("Name");  //this assigns what printHeading will print
    System.out.println("CSC 201-55468 Section 01PR");
    System.out.println("Fall 2012");
    System.out.println("Popcorn Project");
    System.out.println();
    }

}
  • 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-12T11:07:26+00:00Added an answer on June 12, 2026 at 11:07 am
    String inputLine2 =  inputLine.substring(inputLine.indexOf(',') + 1);
    

    This skips the comma, which the original line did not.

    Maybe it is:

    line.skip("[ \t]+");
    

    that is needed to skip the space in front.


    After trying the code with indexOf+1 (without skip):

    ...
    Orville’s Acres43801114.8
    Hoffman’s Hills3622977.2
    Jiffy Quick Farm2481289.4
    Jolly Good Plantation104570183.2
    Organically Grown Inc.1468345.5
    

    Which seems fine, considering:

                System.out.println(farmName + jars + acres);
    

    As this seems homework, I leave it at that.

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

Sidebar

Related Questions

I want to develop the following application: on top I have a navigation bar,
I'm trying to develop a simple racing 2d game (view top-down) in C#, sdl.net.
I would like to develop a custom application (multiple screens, complex processes) on top
I want to develop an application that has a NavigationBar on top, a TableView
I'm about to develop widget that will consume a web service built on top
I want to develop Windows program who can stick into other window. I searching
I want to develop an application that has 4 buttons top and 4 buttons
I am trying to develop/design a main menu/site map for our website. The brief
I want to develop on top of Android using a local Android repository server.
we are trying to develop a web application framework and build implementatins on top

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.