I am programming using a Java Editor called "TextMate" on the mac and it often gives me errors that I don't get when I compile using TextPad on the Windows machines at school. Can someone check if this compiles on a Windows machine please? The errors are under the code, please tell me if you get the same errors. (Program does not seem to recognize variables stated in the main() method.)
Thanks,
Danny
import java.io.*;
import java.text.DecimalFormat;
import java.util.*;
public class Tuition
{
public static void main()
{
int hours = 0;
double fees = 0.0;
double rate = 0.0;
double tuition = 0.0;
displayWelcome();
hours = getHours();
rate = getRate(hours);
tuition = calcTuition(hours, rate);
fees = calcFees(tuition);
displayTotal(tuition + fees);
} //end of main()
public static void displayWelcome()
{
System.out.println("Welcome to Dannys Tuition Calculator!");
} //end displayWelcome()
public static int getHours()
{
String strHours;
int hours = 0;
Scanner scannerIn= new Scanner(System.in);
System.out.print("Please enter the total number of hours: ");
strHours = scannerIn.next();
hours = Integer.parseInt(strHours);
// add try + catch statement
return hours;
} //end of getHours()
public static double getRate(int hours)
{
if (hours > 15)
{
rate = 44.5;
}
else
{
rate = 50.00;
}
return rate;
} //end of getRate
public static double calcTuition(int hour, double rate)
{
tuition = rate * hours;
return tuition;
} //end of calcTuition()
public static double calcFees(double tuition)
{
fees = tuition * 0.08;
return fees;
}//end of calcFees()
public static void displayTotal(double total)
{
DecimalFormat twoDigits = new DecimalFormat("$#,000.00");
System.out.println("The total cost of tuition is: " + twoDigits.format(total) + ".");
} //end of displayTotal()
} //end of Tuition
cannot find symbol
symbol : variable rate
location: class Tuition
rate = 44.5;
^
cannot find symbol
symbol : variable rate
location: class Tuition
rate = 50.00;
^
cannot find symbol
symbol : variable rate
location: class Tuition
return rate;
^
cannot find symbol
symbol : variable tuition
location: class Tuition
tuition = rate * hours;
^
cannot find symbol
symbol : variable hours
location: class Tuition
tuition = rate * hours;
^
cannot find symbol
symbol : variable tuition
location: class Tuition
return tuition;
^
cannot find symbol
symbol : variable fees
location: class Tuition
fees = tuition * 0.08;
^
cannot find symbol
symbol : variable fees
location: class Tuition
return fees;
^
8 errors