Computers & Internet Logo
Posted on Jul 12, 2010

Triangle output in java programming

Triangle output in java

2 Answers

Anonymous

Level 1:

An expert who has achieved level 1.

New Friend:

An expert that has 1 follower.

Mayor:

An expert whose answer got voted for 2 times.

  • Contributor 1 Answer
  • Posted on Oct 04, 2010
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

New Friend:

An expert that has 1 follower.

Mayor:

An expert whose answer got voted for 2 times.

Joined: Oct 04, 2010
Answers
1
Questions
0
Helped
653
Points
5

Anonymous

Level 1:

An expert who has achieved level 1.

MVP:

An expert that got 5 achievements.

Governor:

An expert whose answer got voted for 20 times.

New Friend:

An expert that has 1 follower.

  • Contributor 30 Answers
  • Posted on Jul 23, 2010
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

MVP:

An expert that got 5 achievements.

Governor:

An expert whose answer got voted for 20 times.

New Friend:

An expert that has 1 follower.

Joined: Mar 30, 2010
Answers
30
Questions
0
Helped
7124
Points
49

Import java.util.Scanner; public class triangle { public static void main(String[] args) { double sidea; double sideb; double sidec; Scanner in = new Scanner(System.in); System.out.println("Enter the first side of a triangle: "); sidea = in.nextDouble(); System.out.println("Enter the second side of a triangle: "); sideb = in.nextDouble(); System.out.println("Enter the third side of a triangle: "); sidec = in.nextDouble(); System.out.println("Sides" + " " + sidea + " " + sideb + " " + sidec); if (((sidea * sidea) + (sideb * sideb)) == (sidec * sidec)) System.out.println("right triangle"); if (((sidea * sidea) + (sidec * sidec)) == (sideb * sideb)) System.out.println("right triangle"); if (((sidec * sidec) + (sideb * sideb)) == (sidea * sidea)) System.out.println("right triangle"); //right triangle if ((sidea == sideb) && (sidea == sidec) && (sideb == sidec)) System.out.println("equilateral triangle"); //equilateral triangle if (((sidea == sideb) || (sideb == sidec) || (sidea == sidec)) && !((sidea == sideb) && (sidea == sidec) && (sideb == sidec))) System.out.println("isosceles triangle"); else (!((sidea == sideb) && (sidea == sidec) && (sideb == sidec))) System.out.println("scalene triangle"); //scalene if (((sidea + sideb) >= (sidec)) ||((sidea + sideb) >= (sideb)) ||((sideb +sidec) >= (sidea))) System.out.println("not a triangle"); } }

Ad

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

0helpful
1answer

Tm u220 java

Are you printing from inside a java program (output) or from a java program editor.
Use the command to Open an output file, have all your output sent to the output file, close the output file properly before you exit the java program. After you finish send the output file to the matrix printer as you would with ASCII file. If the printer is installed properly, your OS should know where to send the output.
0helpful
1answer

I am doing research on PC vs Mac for unix programming. What are the differences? Which Platform would be preferred?

That was a rather open question.

As long as the language is standards-based, you should have no problem using the language on any platform where it's certified.

That said, anything related to utilising specific operating-system related features such as GUI are much different, except in Java. Since Java is the same output regardless of platform (but version-specific), you can run it on any platform with the correct version (usually the same or newer) Java Virtual Machine. As mentioned, Java programming is the same on almost any platform. Traditionally, Macs lagged way behind Windows as far as Java releases are concerned, but the lag a lot less now (a few months, sometimes less). Macs also are much more Java-friendly.

Non-Java GUI programming is, as mentioned, much different. Honestly, enough tools exist on both platforms to make GUI programming similar in experience, though much different in actual code.

C, C++ both program the same on either platform (again, GUI code will be platform-specific).

A giant plus to Mac programming is that you have access to all the UNIX-type stuff in a way which is a part of the OS, as opposed to on a PC, where it all needs to be added on. I love the Terminal app on OS X - nothing like it on PCs.

Finally, if you're backed by someone with money, the tools on PCs are a bit better than what OS X has to offer, but not substantially.
0helpful
1answer

The side of the traingle is 4 and the output is * ** *** **** *****

import java.util.*;
public class test {
static Scanner scan = new Scanner(System.in); public static void main(String[] args) {
int mark = scan.nextInt();
for(int i=0; i< mark; i++){ for(int j=0;j<=i;j++) System.out.print("*"); System.out.println(); } } }
0helpful
1answer

I want to make a minor project in core java.....suggest me some new and different projet.....

Program 1
//Find Maximum of 2 nos.

Program 2
//Find Minimum of 2 nos. using conditional operator

/*Write a program to generate 5 Random nos. between 1 to 100, and it
should not follow with decimal point.

* Write a program to generate Harmonic Series.

Display Triangle as follow : BREAK DEMO.

and you can find projects from below link

http://www.freejavaguide.com/javasource3.htm

thanks

0helpful
2answers

Compute the area of triangle

Hi nanaeden

Use the formula depending on what is given
If one side and vertical height from that side to the opposite vertex is given, use the formula 1/2 of basexheight
If 3 sides of the triangle are given use the formula
sq root of [ s(s-a)(s-b)(s-c)] where a,b, c are the 3 sides and s is semi- perimeter.
Familiarise with formulae to solve Maths problems.
If it is helpful, please give a rating.
Have a nice day
luciana44
Nov 25, 2009 • Cell Phones
0helpful
1answer
1helpful
5answers

Can anyone tell how run java program in cmd prompt???

Hi,

You need to type:

If it's a program.class

java program

or of it's a program.jar

java -jar program.jar

regards
0helpful
1answer

Java programming: file access

(R.id.note) this is the error in java, How can I rectify it;
0helpful
3answers

Jawa void

you should not use arguments in void function in java ... in java pertaining to void the compiler doesn't understand the arguments and treats that as invalid... in c it is ok
Not finding what you are looking for?

663 views

Ask a Question

Usually answered in minutes!

Top Sun Computers & Internet Experts

Rob Hill
Rob Hill

Level 3 Expert

1480 Answers

k24674

Level 3 Expert

8093 Answers

Sean Wright
Sean Wright

Level 3 Expert

2045 Answers

Are you a Sun Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...