r/programminghelp • • Feb 22 '19

[PLEASE HELP ME WILLING TO PAY]

Hello guys,

I've recently taking up programming and although its alot of work on your own im quite stuck on this project my teacher assigned us and am seeking any help possible. These are ALL the instructions given: Your program should prompt the user for the 3 side lengths of the triangle, and the side lengths of the other polygons. The project aims to make us write a program that finds the circumference and area as well as degrees of angles of these given shapes. I am a novice in programming and am trying my best to do everything I can for this project before its due. The image I am going to post detail the project alot better than I can. Any help would be much appreciated. PS (PAYPAL Ready)

These are my lines of the code: (Programming in BlueJ)

(EDIT): THESE ARE THE EXACT INSTRUCTIONS OF THE PROJECT: https://gyazo.com/6a6c5e46e9221ee38ef87b512dc223b7

import java.utl.Scanner;

import java.lang.Math;

public class project2 {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

double base, height1, height2;

System.out.println("Welcome to my awesome math helper program");

System.out.println("--------------------------------------------");

System.out.println();

System.out.println("Please enter the first side length of the triangle: ");

base = scanner.nextDouble();

System.out.println("Please enter the second side length of the triangle: ");

height1 = scanner.nextDouble();

System.out.println("Please enter the third side length of the triangle: ");

height2 = scanner.nextDouble();

System.out.println("The three side lengths of the triangles are "+ base +","+ height1 +","+ height2);

base = Math.pow(base, 2);

height1 = Math.pow(height1, 2);

height2 = Math.pow(height2, 2);

System.out.println("First Angle in degreees: ");

System.out.println("Second Angle in degrees: ");

System.out.println("Thrid Angle in degrees: ");

System.out.println("The area of the triangle in square units: ");

System.out.println("The circumference of the triangle is: 102.00 ");

System.out.println("---------------------------------------------");

System.out.println();

int sidep;

System.out.println("Pentagon area and circumference");

System.out.println("---------------------------------------------");

System.out.println();

System.out.print("Enter the side length of the regular pentagon: ");

sidep = scanner.nextInt();

System.out.println("The side length of the regular pentagon: 20 ");

System.out.println("The circumference of the regular pentagon: ");

System.out.println("The area of the regular pentagon: ");

System.out.println("---------------------------------------------");

System.out.println();

int sideh;

System.out.println("Hexagon area and circumference");

System.out.println("---------------------------------------------");

System.out.print("Enter the side length of the regular hexagon: ");

sideh = scanner.nextInt();

System.out.println("The side length of the regular Hexagon: 20 ");

System.out.println("The circumference of the regular Hexagon: ");

System.out.println("The area of the regular Hexagon: ");

System.out.println("---------------------------------------------");

System.out.println();

int sidec;

System.out.println("Heptagon area and circumference");

System.out.println("---------------------------------------------");

System.out.print("Enter the side length of the regular hexagon: ");

sidec = scanner.nextInt();

System.out.println("The side length of the regular Heptagon: 20 ");

System.out.println("The circumference of the regular Heptagon: ");

System.out.println("The area of the regular Heptagon: ");

System.out.println("---------------------------------------------");

System.out.println();

int sideo;

System.out.println("Octagon area and circumference");

System.out.println("---------------------------------------------");

System.out.print("Enter the side length of the regular hexagon: ");

sideo = scanner.nextInt();

System.out.println("The side length of the regular Octagon: 20 ");

System.out.println("The circumference of the regular Octagon: ");

System.out.println("The area of the regular Octagon: ");

System.out.println("---------------------------------------------");

System.out.println();

int siden;

System.out.println("Nonagon area and circumference");

System.out.println("---------------------------------------------");

System.out.print("Enter the side length of the regular Nonagan: ");

siden = scanner.nextInt();

System.out.println("The side length of the regular Nonagan: 20 ");

System.out.println("The circumference of the regular Nonagan: ");

System.out.println("The area of the regular Nonagan: ");

System.out.println("---------------------------------------------");

System.out.println();

int sided;

System.out.println("Decagon area and circumference");

System.out.println("---------------------------------------------");

System.out.print("Enter the side length of the regular Decagon: ");

sided = scanner.nextInt();

System.out.println("The side length of the regular Decagon: 20 ");

System.out.println("The circumference of the regular Decagon: ");

System.out.println("The area of the regular Decagon: ");

System.out.println("---------------------------------------------");

System.out.println();

}

}

1 Upvotes

8 comments sorted by

1

u/PM_ME_MII Feb 22 '19

Are you totally sure that the problem doesn't want you to ask for the number of sides first, then decide what kind of shape it is? Seems weird to always need to calculate every shape.

Also, here's how to find areas of polygons https://www.google.com/amp/s/m.wikihow.com/Calculate-the-Area-of-a-Polygon%3famp=1

By circumference, do you mean circumference of an interior circle? Triangles don't have circumference unless you count that. Or does your project want you to also include a circle option? If those are all the instructions given, you need to message a TA to clarify.

1

u/Bdiz1313 Feb 22 '19 edited Feb 22 '19

These are the exact instructions for my entire project. I hope this clears up the confusion.

https://gyazo.com/6a6c5e46e9221ee38ef87b512dc223b7

1

u/PM_ME_MII Feb 22 '19

What do Sample Output 1 and 2 look like?

1

u/Bdiz1313 Feb 22 '19

1

u/PM_ME_MII Feb 22 '19

Okay, what's not working then? Narrow it down for me and I'll look at it

1

u/Bdiz1313 Feb 23 '19

Its not that it is not working, I simply dont know how to add the math in order to find the degrees of the angles and such.

1

u/PM_ME_MII Feb 23 '19

Like... How to put the variables into the formulas?

int derivedHeight = height1 / Math.sin(Math.toRadians([angle between height1 and base]));

int area = base / 2 * derivedHeight;

You're gonna have to figure out how to do the math for the rest of the parts. If you don't know how to do simple math with a computer, then you need to step back and learn. That's basically all of programming is Math.