I was asked for my AP Comp Sci online course to construct a program that would calculate fahrenheit to celsius and vice versa, the volume of a sphere given the radius, and the hypotenuse of a right triangle given the two other sides. I was given a program to work with to start but it was pretty much all of my programming. They just set up the comments and params and what-not. So I got the error message <identifier> expected over my first System.out.println("..."); line, which meant the console was not identified or imported, but it is clearly identified below. If anyone can help me out with this it'd be appreciated. I'll move onto my next program in the mean time.
public class MathFun
{
/**
* Default Constructor for the MathFun object.
* Does nothing
*/
public MathFun ( ) { }
/**
* Converts a fahrenheit temperature value to celsius
*
* @param fahrenheit temperature in degrees fahrenheit
* @return temperature in degrees celsius
*/
ConsoleIO console = new ConsoleIO();
double f, fToC;
System.out.println("Input temperature in ºF ---> ");
f = console.readDouble();
fToC = (5 / 9)(f - 32);
System.out.println("That is " + Format.right(fToC, 8, 2) + "ºC");
/**
* Converts a celsius temperature value to fahrenheit
*
* @param celsius temperature in degrees celsius
* @return temperature in degrees fahrenheit
*/
double c, cToF
System.out.print("Input temperature in ºC ---> ");
c = console.readDouble();
cToF = (9 / 5)(c) + 32;
System.out.println("That is " + Format.right(cToF, 8, 2) + "ºF");
/**
* Calculates the volume of a sphere
*
* @param r radius of the sphere
* @return volume of the sphere
*/
double r, V, pi
System.out.print("Input radius of a sphere ---> ");
r = console.readDouble();
pi = 3.141592654;
V = (4 / 3)(pi)(r) ^ 3;
System.out.print("That gives the sphere a volume of " + Format.right(V, 8, 2);
/**
* Calculates the hypotenuese of a right triangle
*
* @param sideA length of one side of the right-angle triangle
* @param sideB length of one side of the right-angle triangle
* @return length of the hypotenues
*/
double sideA, sideB, hypsqr, hyp;
System.out.println("Input side A of your right triangle ---> ");
sideA = console.readDouble();
System.out.println("Now input side B ---> ");
sideB = console.readDouble();
hypsqr = ((sideA) ^ 2) + ((sideB) ^ 2);
hyp = ((hypsqr) ^ (1/2));
System.out.println("Those creat a hypotenuse of " + Format.right(hyp, 8, 2);
/**
* The main program for the MathFun class. Gathers input,
* calculates the requested values and formats the output.
*
* @param args The command line arguments (not used)
*/
public static void main(String[] args)
{
MathFun calc = new MathFun();
}
}
Thank again,
-IMtheBESTatJAVA