Hi,
I have a problem with a code i have done but i just a problem..If u look at what i have attached and try to run it..It gave me a problem as i am meant to have a menu which is meant to show something inside it but the menu is coming up but with nothing inside it..I have tried adding ingredients and saving it but still nothing happens..please could anyone help me out..

I couldnt upload the last two so here they are:

UNITCONVERTER.JAVA

  import java.text.DecimalFormat;
  import java.util.HashMap;
  /*
   * The WeightConverter class provides a method to convert a unit to another specified unit
   */


  public class UnitConverter
  {
      private HashMap Units; //The collection which stores the unit objects
      private DecimalFormat myFormatter = new DecimalFormat("#.##");
      public UnitConverter()
      {
          Units=new HashMap();
          //CAPACITY
          Units.put("ml",new Unit("ml",0.001,101));
          Units.put("gills",new Unit("gills",0.142,102));
          Units.put("pt",new Unit("pt",0.568,103));
          Units.put("liter",new Unit("liter",1,104));
          Units.put("qt",new Unit("qt",1.136,105));
          Units.put("gal",new Unit("gal",4.546,106));


          //WEIGHT
          Units.put("mg",new Unit("mg",0.001,201));
          Units.put("cg",new Unit("cg",0.01,202));
          Units.put("gr",new Unit("gr",0.065,203));
          Units.put("gram",new Unit("gram",1,204));
          Units.put("dr",new Unit("dr",1.77,205));
          Units.put("oz",new Unit("oz",28.35,206));
          Units.put("kg",new Unit("kg",1000,207));
          Units.put("lb",new Unit("lb",454,208));
          Units.put("st",new Unit("st",6356,209));
        }

        /**
         * Return a String for new format "number+unit"
         * Parameters: value-the quantity of the unit
         *             unit-the current unit
         *             format-the specified unit
         */
        public String format(double value,String unit,String format)
        {
            String result=null;
            Unit CurrentUnit=(Unit) Units.get(unit.toLowerCase());
            Unit TargetUnit=(Unit) Units.get(format.toLowerCase());
            if(TargetUnit.getMetricRate()==CurrentUnit.getMetricRate())
            {
                result=value+""+unit;
            }
            else
            {
                double temp=value*CurrentUnit.getMetricRate()/TargetUnit.getMetricRate();
                result=myFormatter.format(temp)+""+format;
            }
            return result;
        }
          public double convert(double value,String unit,String format)
          {
              double result=0;
              Unit CurrentUnit=(Unit) Units.get(unit.toLowerCase());
              Unit TargetUnit=(Unit) Units.get(format.toLowerCase());
              if(TargetUnit.getMetricRate()==CurrentUnit.getMetricRate())
              {
                  result=value;
                }
                else
                {
                    double temp=value*CurrentUnit.getMetricRate()/TargetUnit.getMetricRate();
                    result=temp;
                }
                return result;
            }
        }

UNIT.JAVA

/**
 * Write a description of class Unit here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */

/**
 * This is the class of Unit instance
 * The Unit will have a value which means the rate with 1 metric unit for
 * example, 1 litre,1 gram
 */

public class Unit
{
private String name;         //The name of the unit
private double MetricRate;   //The rate of this unit to metric unit
private int index;           //The index of this unit

public Unit(String name,double MetricRate,int index)
{
   this.name=name;
   this.MetricRate=MetricRate;
   this.index=index;
}

public String getName(){return name;}
public double getMetricRate(){return MetricRate;}
public int getIndex(){return index;}
public void setName(String name){this.name=name;}
public void setMetricRate(double MetricRate){this.MetricRate=MetricRate;}
public void setIndex(int index){this.index=index;}}

PLEASE TRY TO RUN EVERYTHING AND SEE WHAT IM TALKING ABOUT...thanx in advance

Member Avatar for iamthwee

f u look at what i have attached and try to run it..It gave me a problem as i am meant to have a menu which is meant to show something inside it but the menu is coming up but with nothing inside it.

So try simplifying your code so it displays just one thing on your menu. If needs be start a new project.

When you simplify it, you eventually get to a stage where you know that only ONE thing may be causing your error. This is an essential part of programming.

Good luck.

Ok would try and do that..

hi sir . I want help . how to write code in frames to accept weight in kilograms in a text field and convert it into grams and milligrams on the click of two separate buttons . display the result in a second text field .

Hi Sravani Kunam, welcome to daniweb.
a few do's and don'ts, though:

DON't hijack dead threads
DO create your own thread for your questions
DON't copy paste your assignment here, expecting us to deliver custom made code
DO show some effort. what have you got so far and what are you stuck with?
DO be specific when asking questions. "Don't work" is way too vague for us to figure out, for instance.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.