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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:05:58+00:00 2026-06-13T12:05:58+00:00

I get the following error when running a drawing program I am working on

  • 0

I get the following error when running a drawing program I am working on for a peersonal project:

Exception in thread "main" java.lang.NumberFormatException: For input string: "100,"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at InputExample.main(InputExample.java:35)

I know what the error means, however since I am just starting out on learning Java I am not 100% how to fix it. Here’s my code so far:

import java.util.Scanner;

public class Input {

    public final static void main(String[] args) {

        GraphicsScreen g = new GraphicsScreen();
        Scanner s = new Scanner(System.in);
        int param1 = -1;
        int param2 = -1;
        String line;
        String command;
        String[] sut;
        System.out
                .println("Please enter your commands here. A list of commands is below to help you get started.");

        do {
            System.out.println("Circle, Move, Draw");
            line = s.nextLine();
        } while(line.equalsIgnoreCase("help") == true);

        sut = line.split(" ");

        command = sut[0];

        if(sut.length > 1) {
            param1 = Integer.parseInt(sut[1]);

            if(sut.length > 2) {
                param2 = Integer.parseInt(sut[2]);
            }
        }

        if(command.equals("Move") == true) {
            g.move(param1, param2);
        }
        else if(command.equals("Draw") == true) {
            g.draw(param1, param2);
        }
        else if(command.equals("Circle") == true) {
            g.circle(param1);
        }
        else {
            System.out
                    .println("The commands you have entered are invalid. Please try again.");
        }
    }
}

So I’ve converted the integer’s to numerical values and passed them through an IF statement to draw shapes on the screen. I’m guessing the error message is something really simple.

  • 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-13T12:05:59+00:00Added an answer on June 13, 2026 at 12:05 pm

    It looks like you need to include the comma in the delimiter for your split – and perhaps make it an optional comma by using ?:

    sut = line.split(",? ");
    

    Another alternative is to remove the comma before parsing:

    sut[1] = sut[1].replaceAll(",$", "")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get the following error when running mongo-hadoop streaming: java.io.IOException: Cannot run program "mapper.py":
I'm trying to freeze my Python3.2 project and get the following error after running
I'm running a simple wordcount program, and I get the following error: Type mismatch
I get the following error when running a c program: *** glibc detected ***
I get the following error when running my Visual Studio 2008 ASP.NET project (start
I get the following error running a pattern matching validation: ErrorException [ Warning ]:
I get the following error when running the code below: invalid byte sequence in
We get the following error when running at test: ContextSwitchDeadlock was detected Message: The
I get the following error when running FXCop: CA1800 : Microsoft.Performance : 'obj', a
When running rspec I get the following error: no such file to load --

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.