DecimalFormat cannot be resolved to a type

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • natvarara
    New Member
    • Aug 2009
    • 7

    DecimalFormat cannot be resolved to a type

    import java.util.*;
    public class cof2 {

    public static void main(String[] args) {
    double latte, mocca, capu ;
    Scanner scannerlatte,sc annermocca,scan nercapu;
    scannerlatte = new Scanner(System. in);
    scannermocca = new Scanner(System. in);
    scannercapu = new Scanner(System. in);
    System.out.prin tln("Plase input number of glasses for");
    latte();
    mocca();
    capu();

    double Alatte = latte * 50 ;
    double Amocca = mocca * 55;
    double Acapu = capu * 60;
    System.out.prin tln("Amount for Latte is" +Alatte+ " Bath");
    System.out.prin tln("Amount for Mocca is" +Amocca+ " Bath");
    System.out.prin tln("Amount for Capuchino is" +Acapu+ "Bath");

    DecimalFormat df = new DecimalFormat(" 0,000");
    double total = Alatte + Amocca + Acapu;
    System.out.prin tln("Grand tatal is"+(total)+"Ba ht");

    }
    public static void latte(){
    System.out.prin tln("Latte : ");
    int latte = scannerlatte.ne xtInt();
    }
    public static void mocca(){
    System.out.prin tln("Mocca: ");
    int mocca = scannermocca.ne xtInt();
    }
    public static void capu(){
    System.out.prin tln("Capuchino : ");
    int capu = scannercapu.nex tInt();
    }
    }
    Error
    Exception in thread "main" java.lang.Error : Unresolved compilation problems:
    DecimalFormat cannot be resolved to a type
    DecimalFormat cannot be resolved to a type
    *************** *************** *************** ***
    I do not understand what it is.
    Error why.
    Do me. Thank U
  • pbrockway2
    Recognized Expert New Member
    • Nov 2007
    • 151

    #2
    Originally posted by natvarara
    Error
    Exception in thread "main" java.lang.Error : Unresolved compilation problems:
    DecimalFormat cannot be resolved to a type
    DecimalFormat cannot be resolved to a type
    *************** *************** *************** ***
    I do not understand what it is.
    The error means that the compiler cannot find the DecimalFormat class. And that's because you have not imported it.

    Try putting the following at the top of your program:

    Code:
    import java.text.DecimalFormat;

    Comment

    Working...