Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question
100%

public class Geometry
{
public static void main(String[] args)
{
//asks for user's choice
Scanner in = new Scanner(System.in);
displayMenu();
selectOption(choice);
System.out.println("Enter your choice (1-3): ");
int choice1 = in.nextInt();

System.out.println("Thanks for using the Geometry Calculator - Goodbye!");



//Prints if input is a number that is not one of the choices
while(choice1 < 1 || choice1 > 3 )
{
System.out.println("Invalid choice. Please enter 1 - 3: ");
choice1 = in.nextInt();
}
}
/**

Displays the menu

*/
public static void displayMenu()
{
System.out.println("Welcome to the Geometry Calculator Application");
System.out.println("1. Calculate the Area of a Circle");
System.out.println("2. Calculate the Area of a Rectangle");
System.out.println("3. Calculate the Area of a Triangle");
}
/**
This method calculates the area of the circle

@return the area of the circle

*/
public static double circle()// calculates the area of the circle
{
Scanner in = new Scanner(System.in);
System.out.println("What is the circle's radius? ");
double radius = in.nextDouble();
double circleArea = Math.PI * radius * radius;
return circleArea;
}
/**
This method calculates the area of rectangle
@result the area of the rectangle
*/
public static double rectangle()// calculates the area of the rectangle
{
Scanner in = new Scanner(System.in);
System.out.println("What is the rectangle's length? ");
double length = in.nextDouble();
System.out.println("What is the rectangle's width? ");
double width = in.nextDouble();
double rectangleArea = length * width;
return rectangleArea;
}

//calculates the area of a triangle
/**
This method calculates the area of a triangle
@return the area of the triangle
*/
public static double triangle()
{
Scanner in = new Scanner(System.in);
System.out.println("What is the length of the triangle's base? ");
double base = in.nextDouble();
System.out.println("What is the triangle's height? ");
double height = in.nextDouble();
double triangleArea = 0.5 * base * height;
return triangleArea;
}

//prints area to two decimal places
/**
This method prints the area
@param the area's value
*/
public static void printArea(double a)
{
System.out.printf("The area is "+ "%.2f" + a);
}

//assigns each choice to a method
/**
This method assigns each choice to an area method
@param choice of the method
*/
public static void selectOption(int choice)
{
if(choice==1)
{
circle();
printArea(circleArea()); //prints circle's area if the choice is #1
}
else if(choice==2)
{
rectangle();
printArea(rectangleArea); //prints rectangle's area if the choice is #2
}
else if(choice==3)
{
triangle();
printArea(triangleArea); //prints triangle's area if the choice is #3
}
}
}




This is my code for calculating the area. 

 

These are the errors I get.

Geometry.java:17: error: cannot find symbol
selectOption(choice);
^
symbol: variable choice
location: class Geometry
Geometry.java:109: error: cannot find symbol
printArea(circleArea); //prints circle's area if the choice is #1
^
symbol: variable circleArea
location: class Geometry
Geometry.java:114: error: cannot find symbol
printArea(rectangleArea); //prints rectangle's area if the choice is #2
^
symbol: variable rectangleArea
location: class Geometry
Geometry.java:119: error: cannot find symbol
printArea(triangleArea); //prints traingle's area if the choice is #3
^
symbol: variable triangleArea
location: class Geometry
4 errors

I would appreciate help in this!

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education