Question

In: Computer Science

This is an intro to java question. Please post with pseudocode and java code. Problem should...

This is an intro to java question. Please post with pseudocode and java code.

Problem should be completed using repetition statements like while and selection statements.

Geometry (10 points) Make API (API design) Java is an extensible language, which means you can expand the programming language with new functionality by adding new classes. You are tasked to implement a Geometry class for Java that includes the following API (Application Programming Interface): Geometry Method API: Modifier and Type Method and Description static double getAreaRectangle(double width, double length) Returns the area of a rectangle, area = length * width static double getAreaCircle(double radius) Returns the area of a circle, area = ?(radius 2 ) static double getAreaTriangle(double base, double height) Returns the area of a triangle, area = ½(base * height) static double getPerimeterRectangle(double width, double length) Returns the perimeter of a Rectangle, perimeter = 2(length + width) static double getPerimeterCircle(double radius) Returns the perimeter of a Circle, perimeter = 2?(radius) static double getPerimeterTriangle(double side1, double side2, double side3) Returns the perimeter of a triangle, perimeter = s1 + s2 + s3 Facts ● Java Math class contains an approximation for PI, i.e. Math.PI ● Your Geometry class implementation should not have a main method. ● NO Scanner for input & NO System.out for output! Input The Geometry class will be accessed by an external Java Application within Autolab. This Java app will send data in as arguments into each of the methods parameters. Output The Geometry class should return the correct data calculations back to the invoking client code

Sample Method Calls

getAreaRectangle(1,1);

getAreaCircle(1);

getAreaTriangle(1,1);

getPerimeterRectangle(1,1);

getPerimeterCircle(1);

getPerimeterTriangle(1,1,1);

Sample Method Returns

1.0

3.141592653589793

0.5

4.0

6.283185307179586

3.0

Solutions

Expert Solution

CODE

class Geometry {

static double getAreaRectangle(double width, double length) {

return width * length;

}

static double getAreaCircle(double radius) {

return Math.PI * radius * radius;

}

static double getAreaTriangle(double base, double height) {

return 0.5 * base * height;

}

static double getPerimeterRectangle(double width, double length) {

return 2 * (width + length);

}

static double getPerimeterCircle(double radius) {

return 2 * Math.PI * radius;

}

static double getPerimeterTriangle(double side1, double side2, double side3) {

return (side1 + side2 + side3);

}

}

public class Main {

public static void main(String[] args) {

System.out.println(Geometry.getAreaRectangle(1,1));

System.out.println(Geometry.getAreaCircle(1));

System.out.println(Geometry.getAreaTriangle(1,1));

System.out.println(Geometry.getPerimeterRectangle(1,1));

System.out.println(Geometry.getPerimeterCircle(1));

System.out.println(Geometry.getPerimeterTriangle(1,1,1));

}

}


Related Solutions

This is an Intro to java question. Please provide code and pseudocode for better understanding. Problem...
This is an Intro to java question. Please provide code and pseudocode for better understanding. Problem 4: Player Move Overworld (10 points) (Game Development) You're the lead programmer for an indie game studio making a retro-style game called Zeldar. You've been tasked to implement the player movement. The game is top-down, with the overworld modeled as a 2d grid. The player's location is tracked by x,y values correlating to its row and column positions within that grid. Given the current...
This is an intro to java question. Please answer with pseudocode and code. Problem 2: RSA...
This is an intro to java question. Please answer with pseudocode and code. Problem 2: RSA Public Key (10 points) (Cyber Security) RSA is an asymmetric encryption scheme, where a public key is used to encrypt data and a different, private key decrypts that data. RSA public/private keys are generated from two prime numbers, typically very large ones. The idea behind RSA is based on the fact that its difficult to factorize very large integers. RSA public key generation is...
This is an Intro to Java Question, Please respond with code and pseudocode. Problem 3: RSA...
This is an Intro to Java Question, Please respond with code and pseudocode. Problem 3: RSA Private Key (10 points) (Cyber Security) In the RSA algorithm, encrypting and decrypting a message is done using a pair of numbers that are multiplicative inverses with respect to a carefully selected modulus. In this task, you must calculate the modular multiplicative inverse for given set of values. What is the Modular Multiplicative Inverse? In mathematics, each operation typically has an inverse. For example,...
Intro to java Problem, Please provide code and Pseudocode. Not able to compile correct numbers. Problem...
Intro to java Problem, Please provide code and Pseudocode. Not able to compile correct numbers. Problem 7: Simple Calculator (10 points) (General) Calculators represent the most basic, general-purpose of computing machines. Your task is to reduce your highly capable computer down into a simple calculator. You will have to parse a given mathematical expression, and display its result. Your calculator must support addition (+), subtraction (-), multiplication (*), division (/), modulus(%), and exponentiation (**). Facts ● Mathematical expressions in the...
Intro to Java Question. Please Provide code and pseudocode for understanding. Not receiving correct results currently....
Intro to Java Question. Please Provide code and pseudocode for understanding. Not receiving correct results currently. Problem 5: Player Move Dungeon (10 points) (Game Development) You're the lead programmer at a AAA studio making a sequel to the big hit game, Zeldar 2. You've been challenged to implement player movement in dungeons. The game is top-down, with dungeons modeled as a 2d grid with walls at the edges. The player's location is tracked by x,y values correlating to its row...
This is an entry to Java Question. Please answer with Pseudocode and Java code for better...
This is an entry to Java Question. Please answer with Pseudocode and Java code for better understanding. We are mainly using basic in and out declarations and are focusing on API for method invocations. Any help would be very appreciated :) Problem 7: Distance (10 points) Use API (Data Science) Data Science is an emergent field from Computer Science with applications in almost every domain including finances, medical research, entertainment, retail, advertising, and insurance. The role of a data analyst...
Java Problem: Please answer both parts of the question fully: (a). Write Java code for a...
Java Problem: Please answer both parts of the question fully: (a). Write Java code for a method to test if a LinkedList<Long> has Long values that form a Fibonacci sequence from the beginning to the end and return true if it is and false otherwise. A sequence of values is Fibonnaci if every third value is equal to sum of the previous two. Eg., 3,4,7,11,18,29 is a Fibonacci sequence whereas 1,2,3,4 is not, because 2+3 is not equal to 4....
(I AM IN A INTRO TO PROGRAMMING, PLEASE USE SIMPLE PSEUDOCODE IF POSSIBLE) Create pseudocode for...
(I AM IN A INTRO TO PROGRAMMING, PLEASE USE SIMPLE PSEUDOCODE IF POSSIBLE) Create pseudocode for a program for Hansel's Housecleaning Service. The program prompts the user for a customer's last name only. While the last name is not “zzz” your program will ask for the number of bathrooms and the number of other rooms to be cleaned and display the cleaning charge. You should use a sentinel-controlled while loop in your main loop logic. A customer name of “zzz”...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import...
Please I can get a flowchart and a pseudocode for this java code. Thank you //import the required classes import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class BirthdayReminder {       public static void main(String[] args) throws IOException {        // declare the required variables String sName = null; String names[] = new String[10]; String birthDates[] = new String[10]; int count = 0; boolean flag = false; // to read values from the console BufferedReader dataIn = new BufferedReader(new...
The following problem should be done in pseudocode. Problem 1 The programmer intends for this pseudocode...
The following problem should be done in pseudocode. Problem 1 The programmer intends for this pseudocode to display three random numbers in the range of 1 through 7. According to the way we've been generating random numbers in the book; however, there appears to be an error. Assume that the random() function is a built-in library function. Correct the pseudocode so that the program works as it should (This has 1 error and is easy to spot) //This program displays...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT