brennydoogles
February 23rd, 2008, 02:22 AM
I am new to java, and for one of my classes at school I have to write a Java class to create "Table" objects for a restaurant type setting. There are several constants, such as the tax rate and the prices of the meals, but when I try to compile, I am getting errors about the data type. In the instructions for the project, my professor said that we needed to return floats for several methods, but javac is throwing out these errors:
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:36: possible loss of precision
found : double
required: float
private final float APPETIZER = 3.25; // Declare and set APPETIZER constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:37: possible loss of precision
found : double
required: float
private final float ENTREE = 10.75; // Declare and set ENTREE constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:38: possible loss of precision
found : double
required: float
private final float DESSERT = 4.50; // Declare and set DESSERT constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:39: possible loss of precision
found : double
required: float
private final float DRINK = 1.20; // Declare and set DRINK constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:40: possible loss of precision
found : double
required: float
private final float TAX = .09; // Declare and set TAX constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:41: possible loss of precision
found : double
required: float
private final float TIP = .15; // Declare and set TIP constant
^
6 errors
Maybe I don't understand primitive data types as well as I thought I did, but I though the only difference was that doubles had 14 places of accuracy while float only had 7. Can anyone help me figure out what I am doing wrong??
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:36: possible loss of precision
found : double
required: float
private final float APPETIZER = 3.25; // Declare and set APPETIZER constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:37: possible loss of precision
found : double
required: float
private final float ENTREE = 10.75; // Declare and set ENTREE constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:38: possible loss of precision
found : double
required: float
private final float DESSERT = 4.50; // Declare and set DESSERT constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:39: possible loss of precision
found : double
required: float
private final float DRINK = 1.20; // Declare and set DRINK constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:40: possible loss of precision
found : double
required: float
private final float TAX = .09; // Declare and set TAX constant
^
/home/brendon/Documents/csci 1250/workspace/Meals/src/Meals.java:41: possible loss of precision
found : double
required: float
private final float TIP = .15; // Declare and set TIP constant
^
6 errors
Maybe I don't understand primitive data types as well as I thought I did, but I though the only difference was that doubles had 14 places of accuracy while float only had 7. Can anyone help me figure out what I am doing wrong??