I am trying to write a Geometry.java program but Dr.Java is
giving me errors and I dont know what I am doing wrong.
import java.util.Scanner;
/**
This program demonstrates static methods
*/
public class Geometry
{
public static void main(String[] args)
{
int choice; // The user’s choice
double value = 0; // The method’s return value
char letter; // The user’s Y or N decision
double radius; // The radius of the circle
double length; // The length of the rectangle
double width; // The width of the rectangle
double height; // The height of the triangle
double base; // The base of the triangle
double side1; // The first side of the triangle
double side2; // The second side of the triangle
double side3; // The third side of the triangle
// Create a scanner object to read from the keyboard
Scanner keyboard = new Scanner(System.in);
// The do loop allows the menu to be displayed first
do
{
// TASK #1 Call the printMenu method
printMenu();
choice = keyboard.nextInt();
switch(choice)
{
case 1:
System.out.print(“Enter the radius of ” +
“the circle: “);
radius = keyboard.nextDouble();
// TASK #3 Call the circleArea method and
// store the result in the value variable
value=cirArea(radius);
System.out.println(“The area of the ” +
“circle is ” + value);
break;
case 2:
System.out.print(“Enter the length of ” +
“the rectangle: “);
length = keyboard.nextDouble();
System.out.print(“Enter the width of ” +
“the rectangle: “);
width = keyboard.nextDouble();
// TASK #3 Call the rectangleArea method and
// store the result in the value variable
value=recArea(length, width);
System.out.println(“The area of the ” +
“rectangle is ” + value);
break;
case 3:
System.out.print(“Enter the height of ” +
“the triangle: “);
height = keyboard.nextDouble();
System.out.print(“Enter the base of ” +
“the triangle: “);
base = keyboard.nextDouble();
// TASK #3 Call the triangleArea method and
// store the result in the value variable
value=triArea(base,height);
System.out.println(“The area of the ” +
“triangle is ” + value);
break;
case 4:
System.out.print(“Enter the radius of ” +
“the circle: “);
radius = keyboard.nextDouble();
// TASK #3 Call the circumference method and
// store the result in the value variable
value= cirCircumference(radius);
System.out.println(“The circumference ” +
“of the circle is ” +
value);
break;
case 5:
System.out.print(“Enter the length of ” +
“the rectangle: “);
length = keyboard.nextDouble();
System.out.print(“Enter the width of ” +
“the rectangle: “);
width = keyboard.nextDouble();
// TASK #3 Call the perimeter method and
// store the result in the value variable
value=recPerimeter(length,width);
System.out.println(“The perimeter of ” +
“the rectangle is ” +
value);
break;
case 6:
System.out.print(“Enter the length of ” +
“side 1 of the ” +
“triangle: “);
side1 = keyboard.nextDouble();
System.out.print(“Enter the length of ” +
“side 2 of the ” +
“triangle: “);
side2 = keyboard.nextDouble();
System.out.print(“Enter the length of ” +
“side 3 of the ” +
“triangle: “);
side3 = keyboard.nextDouble();
// TASK #3 Call the perimeter method and
// store the result in the value variable
value=triPerimeter(side1,side2,side3);
System.out.println(“The perimeter of ” +
“the triangle is ” +
value);
break;
default:
System.out.println(“You did not enter ” +
“a valid choice.”);
}
keyboard.nextLine(); // Consume the new line
System.out.println(“Do you want to exit ” +
“the program (Y/N)?: “);
String answer = keyboard.nextLine();
letter = answer.charAt(0);
} while(letter != ‘Y’ && letter != ‘y’);
}
// TASK #1 Create the printMenu method here
public static void printMenu(){
System.out.println(“This is a geometry calculator”);
System.out.println(“Choose what you would like to
calculate”);
System.out.println(“1. Find the area of a circle”);
System.out.println(“2. Find the area of a rectangle”);
System.out.println(“3.Find the area of a triangle”);
System.out.println(“4. Find the circumference of a circle”);
System.out.println(“5. Find the perimeter of a rectangle”);
System.out.println(“6. Find the perimeter of a triangle Enter the
number of your choice:”);
// TASK #2 Create the value-returning methods here
/**
*
*
*
*/
public static double cirArea(double radius)
{
return Math.Pi*radius*radius;
}
/**
*
*
*
*/
public static double recArea(double length,double width){
return lenght*width;
}
/**
*
*
*
*/
public static double triArea(double base,double height){
return 0.5*base*height;
}
/**
*
*
*
*/
public static double cirCircumference(double radius){
return 2*Math.Pi*radius;
}
/**
*
*
*/
public static double recPerimeter(double length,double
width){
return 2*(length+width);
}
/**
*
*
*/
public static double triPerimeter(double side1,double side2,double
side3);
{
return side1+side2+side3;
}
// TASK #4 Write javadoc comments for each method
}
}
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.