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

  • Home
  • SEARCH
  • 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 8391095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:10:13+00:00 2026-06-09T19:10:13+00:00

This simple program should be able to get the Markup percentage and the wholesale

  • 0

This simple program should be able to get the Markup percentage and the wholesale Cost and calculate the retail price i put an action listener to the CALCULATE button but when i press the calculate button this error appears:

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: 
For input string: "Enter the markup precentage" 
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source) 
at java.lang.Double.parseDouble(Unknown Source) 
at mm$CalcListerner.actionPerformed(mm.java:58) 
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) 
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) 
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) 
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)

Can someone help me with this issue?

Can someone please explain these error messages because I don’t really get any of that?

My code is:

import javax.swing.*;
import java.awt.event.*;

public class mm extends JFrame {

    private JTextField WholesaleCost;
    private JTextField markupPresentage;
    private JLabel WCost;
    private JLabel MPrecentage;
    private JButton button;
    private JPanel pannel;
    private final int Width = 250;
    private final int height = 320;

    public mm() {
        setTitle("Retail Price Calculator");
        setSize(Width, height);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setVisible(true);
        buildPanel();
        add(pannel);
    }

    private void buildPanel() {
        WholesaleCost = new JTextField(10);
        markupPresentage = new JTextField(10);

        WCost = new JLabel("enter the Whole Sale cost");
        MPrecentage = new JLabel("Enter the markup precentage");

        button = new JButton("Calculate");
        button.addActionListener(new CalcListerner());

        pannel = new JPanel();
        pannel.add(WholesaleCost);
        pannel.add(markupPresentage);
        pannel.add(WCost);
        pannel.add(MPrecentage);
        pannel.add(button);
    }

    private class CalcListerner implements ActionListener {

        public void actionPerformed(ActionEvent e) {
            String WSaleinput;
            String MPres;
            WSaleinput = WholesaleCost.getText();
            MPres = MPrecentage.getText();

            double Value = Double.parseDouble(WSaleinput) * (Double.parseDouble(MPres) / 100);

            JOptionPane.showMessageDialog(null, "Retail Price is  " + Value);
        }
    }

    public static void main(String[] args) {
        mm x = new mm();
    }
}
  • 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-09T19:10:14+00:00Added an answer on June 9, 2026 at 7:10 pm

    You’re trying to reference the wrong component.

    This

    WSaleinput=WholesaleCost.getText();
    MPres =MPrecentage.getText();
    

    Should actually be

    WSaleinput = WholesaleCost.getText();
    MPres = markupPresentage.getText();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I was writing this simple program to calculate the day of any date
I'm trying to get this simple program to work on windows, but it crashes:
I have created this simple program to learn shared_ptr using namespace std; #define Yes
I have this simple program that computes salaries for four different worker types. It's
I'm trying to compile this simple program to start learning how to use timers:
So I made this (very simple) program with a swing GUI with NetBeans, and
I've created this simple example program, but this doesn't work. it won't connect. any
This is my simple program in Java: public class Counter extends Thread { public
I was making this very simple lex program (just an introductory program). But on
This is a really simple program I'm writing here but came up to the

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.