I've been having trouble with this code for about a week and I've finally got it down to one error. Here is the code:
import java.util.Scanner;
public class Triangle {
public static void main (String[] args) {
Scanner Console = new Scanner(System.in);
System.out.print("Please enter the three lengths of your Triangle: ");
double a = console.nextDouble();
[Code] ....
And here is the error:
Triangle.java:30: error: class, interface, or enum expected
} // End class
^
1 error
I'm doing a problem where the area of a triangle is returned (if valid). However, I want to return a message (i.e. 'triangle is not valid) if the triangle is invalid.
I'm not sure how to go about to doing this as my method (called area) will only let me return doubles. Possible to return a string in an else within my area method?
public class MyTriangle { public static void main(String[] args) { //triangle is valid if the sum of any two sides is bigger than the third System.out.println(isValid(3, 4, 5)); System.out.println(area(543, 4, 5));
package areatest; import javax.swing.JOptionPane; public class AreaTest {
public static double areaTriangle (double length, double width){ //How to calculate the area of a triangle return .5f * length * width;
[Code] .....
When I try to get the area of a rectangle it gives me 9 no matter what input I give it. When I try to get the area of a triangle it gives me .5 no matter what input I give it. Same with the circle but it always gives me 12.56370...
import javax.swing.JOptionPane; import java.util.*; import java.text.DecimalFormat; import java.util.StringTokenizer; public class ShelbyHarms_3_03 { public static void main (String [] args) { double a, b, c; //Input sides of triangle double x; //Perimeter of triangle double area; //Area of triangle
[Code] .....
Here are the errors:
ShelbyHarms_3_03.java:39: error: variable x might not have been initialized JOptionPane.showMessageDialog(null, formatter.format(x)); ^ ShelbyHarms_3_03.java:42: error: variable area might not have been initialized JOptionPane.showMessageDialog(null, formatter.format(area)); ^ 2 errors
I started with finding the area of a triangle, but now I'm trying to ask a user what kind of shape they want the area for, then ask questions to get the area. I can't figure out how to take the shape a person types to go to a certain case. It also says shape hasn't been initialized. I don't know how to do that.
import java.util.Scanner; public class TriangleArea { static Scanner sc = new Scanner(System.in); public static void main(String[] args){ char shape; String text = "Do you want to find the area of a triangle, square, rectangle, or trapezoid?"; System.out.print("Text"); switch(shape){
Basically its a program where a user is prompted to enter the length of all three sides of a triangle and the program calculates the area by herons formula and can tell if the triangle is equilateral or Pythagorean. I am having trouble entering a formula to where all three enter sides cant possibly be a triangle. Here is my Program. Where the '?' is stated.
import java.util.Scanner; public class Triangle { public static void main(String[] args){ double a; double b; double c; double s; double x; double area;
Write a Java program that calculates the area and volume of a cube, sphere, cylinder, and regular tetrahedron. Your program should obtain the necessary input for each of the objects from the console and output the input, area, and volume of the object. Use appropriate messages to guide the user of your program.
Here what i did, i am not sure if this is what the assignment want, but this is the best method i could come up with
//Khang Le import java.util.Scanner; public class InputAreaVolume { public static void main(String[] args) {
I am having trouble getting my main triangle program to run. My teacher gave us a sample program, so I tried running his, and it doesn't run either.
Here is the class:
import java.util.Scanner; public class ShelbyHarms_3_06_Triangle { private double sideA, sideB, sideC; // Instance variables, numbers for area and perimeter static Scanner console = new Scanner(System.in); // Establish keyboard
[Code] .....
My errors for the main program(the class has no errors) are:
helbyHarms_3_06.java:37: error: cannot find symbol theSides.getSides(); ^ symbol: variable theSides location: class ShelbyHarms_3_06
I'm starting with my version of very basic program: calculating area of circle. And of course it doesn't get well. My question: what is wrong in this code?
public class circleAre{ double radious; void putData(double radi){ radi = radious;
Here is the program I wrote for calculating the circumference of a circle.
//circumference.java //program that calculates the area and circumference of a circle import java.util.Scanner; //program uses class scanner public class circumference{ //main method begins execution of Java application public static void main(String args[]){
[Code] .....
Even though my code compiles and runs without any errors, the program doesn't calculate the circumference.
I have to write a gui program where I can enter a file name and then it gets displayed in a text area when I click Open. Conceptually, I do not get this. I was thinking of appending the text file into a string or something, but I guess I'm confused on how it all works and how I can open the text file. Not asking for the code, but just a compass or something.
I want to do an app that capture a selected area of a screen and save it. I did a few research and i did the code down below.
My questions are:
1 - How can i open a pdf file in this app ? (i tried use a method but it didnt work. I dont know exactly where to put it on the code)
2 - How can i save the selected area in a new file ? (a image file : JPEG, JPG,png)
3 - [the complex part] right now, the code only "save" one selected area each time. I want to capture a lot of parts of screen and save this in the same image file. one beside the other. How can i do this ?
A triangle is defined by the x- and y- coordinates of its three corner points. Compute the following the following properties of a given triangle: the lengths of all sides, the angles at all corners, the perimeter and the area. The program must prompt a user for the point coordinates. I have created a class Triangle and a class TriangleSimulator, I am stuck and can't figure out why my program won't run correctly.
import java.util.Scanner; public class Triangle { Scanner in = new Scanner(System.in); private int x1; private int x2; private int x3;
class triangle { public static void main (String[] args) { System.out.println("Provide three side lengths - 000 to terminate."); int a = In.getInt(); int b = In.getInt(); int c = In.getInt();
[code]....
My problem is that when I enter 5,2,5 it should be isosceles and acute but it comes out as isosceles and obtuse, and when I type 5,5,5 it comes out equilateral and right. The only one that works is if I enter 3,5,4 it will come out as scalene and right. I been at this for a while and my math looks correct.
class shape{ public static void main(String [] args){ for(int x =0 ; x<=6;x++){ for(int y =0 ; x > y ; y++){ System.out.print(x); } System.out.print(" "); } } }
I'm trying to make a triangle that plots the point in where the corners show their position in the window and also that the user may drag each corner to a desired position.
I am trying to make a program that prints triangle... and I did various test on each method to realise that the problem lies with this segment.When I call this method, nothing prints out, I figure there is something with the loop that I am not realizing.the loop is backwards because it's supposed to have the right side edge parralel (when I try to print it out the spaces do not appear, imagine the x are space...), so as each line is looped the # of spaces diminishes
xxxx* xxx*x* xx*xx* x*xxx* *****
public class test { public static void main(String[] args){ for (int countdown = 5; countdown <= 1; countdown = countdown--){ showNTimes(countdown, ' '); showNTimes(5- countdown, '*'); System.out.println(""); } } public static void showNTimes ( int nbTimes, char carac ) { for ( int i = 1 ; i <= nbTimes ; i = i + 1 ) { System.out.print( carac ); } } }
I'm new to JavaFX and I'm exploring its 3D capabilities, and in particular the TriangleMesh visualisation.
I have developed a very basic application, based on the Molecule Sample Application provided in the examples, that read a mesh file generated by an external tool (Gmsh) and displays it. Pretty basic.
My problem is that the rendering is not what I expected (see attachement)
My guess is that I got something wrong with the texture coordinates or the triangles orientation.
- I don't what to have textures attached to my meshes. These are 3D meshes used for scientific simulation purposes. I thus have set all texCoords to 0. - I don't control the orientation of my triangles, they are generated by Gmsh. Their orientation is also not interesting for my end users so I would like to display all triangles the same way. I used the meshView.setCullFace(CullFace.NONE); method.