When I compile this program it says "cannot find symbol class Method Master", but when I run it, everything is fine.
/*
*Andrew Davis
*Nov. 19, 2010
*/
import java.util.Scanner;
public class Calculator
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
MethodMaster method = new MethodMaster();
int question1;
double num1;
double num2;
double length;
double width;
double side1;
double side2;
double side3;
double base;
double height;
double radius;
double fahrenheit;
double centigrade;
double value = 0;
method.printMenu();
question1 = keyboard.nextInt();
System.out.println();
switch(question1)
{
case 1: //Add two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " + " + num2 + " = " + method.addNumbers(num1, num2, value));
break;
}
case 2: //Subtract two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " - " + num2 + " = " + method.subtractNumbers(num1, num2, value));
break;
}
case 3: //Multiply two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " * " + num2 + " = " + method.multiplyNumbers(num1, num2, value));
break;
}
case 4: //Divide two numbers.
{
System.out.print("Enter the first number: ");
num1 = keyboard.nextDouble();
System.out.print("Enter the seccond number: ");
num2 = keyboard.nextDouble();
System.out.println(num1 + " / " + num2 + " = " + method.divideNumbers(num1, num2, value));
break;
}
case 5: //Find the perimeter of a rectangle.
{
System.out.print("Enter the LENGTH: ");
length = keyboard.nextDouble();
System.out.print("Enter the WIDTH: ");
width = keyboard.nextDouble();
System.out.println("Rectangle P = " + method.rectanglePerimeter(length, width, value));
break;
}
case 6: //Find the perimeter of a triangle.
{
System.out.print("Enter the length of SIDE 1: ");
side1 = keyboard.nextDouble();
System.out.print("Enter the length of SIDE 2: ");
side2 = keyboard.nextDouble();
System.out.print("Enter the length of SIDE 3: ");
side3 = keyboard.nextDouble();
System.out.println("Triangle P = " + method.trianglePerimeter(side1, side2, side3, value));
break;
}
case 7: //Find the area of a rectangle.
{
System.out.print("Enter the LENGTH: ");
length = keyboard.nextDouble();
System.out.print("Enter the WIDTH: ");
width = keyboard.nextDouble();
System.out.println("Rectangle A = " + method.rectangleArea(length, width, value));
break;
}
case 8: //Find the area of a triangle.
{
System.out.print("Enter the BASE: ");
base = keyboard.nextDouble();
System.out.print("Enter the HEIGHT: ");
height = keyboard.nextDouble();
System.out.println("Triangle A = " + method.triangleArea(base, height, value));
break;
}
case 9: //Find the circumferance of a circle.
{
System.out.print("Enter the RADIUS: ");
radius = keyboard.nextDouble();
System.out.print("Circle C = " + method.circleCircumference(radius, value));
break;
}
case 10: //Fahrenheit to Centigrade.
{
System.out.print("Enter the temperature(F): ");
fahrenheit = keyboard.nextDouble();
System.out.print(method.fahrenheitToCentigrade(fahrenheit) + "C");
break;
}
case 11: //Centigrade to Fahrenheit.
{
System.out.print("Enter the temperature(C): ");
centigrade = keyboard.nextDouble();
System.out.print(method.centigradeToFahrenheit(centigrade) + "F");
break;
}
}
}
}
/*
*Andrew Davis
*Nov. 19, 2010
*
*This program contains all methods.
*/
public class MethodMaster
{
public void printMenu()
{
System.out.println("Choose what you would like to calculate: ");
System.out.println(" 1. Add two numbers");
System.out.println(" 2. Subtract two numbers");
System.out.println(" 3. Multiply two numbers");
System.out.println(" 4. Divide two numbers");
System.out.println(" 5. Find the perimeter of a rectangle");
System.out.println(" 6. Find the perimeter of a triangle");
System.out.println(" 7. Find the area of a rectangle");
System.out.println(" 8. Find the area of a triangle");
System.out.println(" 9. Find the circumference of a circle");
System.out.println(" 10. Fahrenheit to Centigrade");
System.out.println(" 11. Centigrade to Fahrenheit");
System.out.print("Enter the number of your choice: ");
}
// 1. Add two numbers.
public double addNumbers(double num1, double num2, double value1)
{
value1 = num1 + num2;
return value1;
}
// 2. Subtract two numbers.
public double subtractNumbers(double num1, double num2, double value1)
{
value1 = num1 - num2;
return value1;
}
// 3. Multiply two numbers.
public double multiplyNumbers(double num1, double num2, double value1)
{
value1 = num1 * num2;
return value1;
}
// 4. Divide two numbers.
public double divideNumbers(double num1, double num2, double value1)
{
value1 = num1 / num2;
return value1;
}
// 5. Find the perimeter of a rectangle.
public double rectanglePerimeter(double length1, double width1, double value1)
{
value1 = (length1 + width1) * 2;
return value1;
}
// 6. Find the perimeter of a triangle.
public double trianglePerimeter(double side1, double side2, double side3, double value1)
{
value1 = side1 + side2 + side3;
return value1;
}
// 7. Find the area of a rectangle.
public double rectangleArea(double length1, double width1, double value1)
{
value1 = length1 * width1;
return value1;
}
// 8. Find the area of a triangle.
public double triangleArea(double base1, double height1, double value1)
{
value1 = 0.5 * (base1 * height1);
return value1;
}
// 9. Find the circumference of a circle.
public double circleCircumference(double radius1, double value1)
{
value1 = (2 * radius1) * 3.14159265;
return value1;
}
// 10. Fahrenheit to Centigrade.
public double fahrenheitToCentigrade(double fahrenheit1)
{
double centigrade1 = 5.0 / 9.0 * (fahrenheit1 - 32);
return centigrade1;
}
// 11. Centigrade to Fahrenheit.
public double centigradeToFahrenheit(double centigrade1)
{
double fahrenheit1 = 9.0 / 5.0 * (centigrade1 + 32);
return fahrenheit1;
}
}