Home Answers Viewqa Java-Beginners Functions and Methods

 
 


ujjwal
Functions and Methods
1 Answer(s)      a year ago
Posted in : Java Beginners

Write a Java program to input the sides of a triangle. Pass the sides to a function decide(int x,int y,int z) which checks and prints whether the triangle is equilateral,isosceles or scalene.

View Answers

May 16, 2012 at 5:52 PM


The given code accepts the sides of triangle from the user. Pass the sides to a function decide(int x,int y,int z) which checks and prints whether the triangle is equilateral,isosceles or scalene.

import java.util.*;

class TypeOFTriangle 
{
    public static void decide(int side1,int side2,int side3){
        String type="";
            if(side1 == side2 && side2 == side3){
            type = "Equilateral";
            }
            else if(side1 == side2 && side2 != side3){
            type = "Isosceles";
            }
            else if(side1 == side3 && side2 != side3){
            type = "Isosceles";
            }
            else if(side1 != side3 && side2 == side3)
            type = "isosceles";

            else
            type = "Scalene";

            System.out.println(type);
    }
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter side 1: ");
        int side1=input.nextInt();

        System.out.print("Enter side 2: ");
        int side2=input.nextInt();

        System.out.print("Enter side 3: ");
        int side3=input.nextInt();

        decide(side1,side2,side3);

    }
}









Related Pages:
Functions and Methods
Functions and Methods  Write a Java program to input the sides of a triangle. Pass the sides to a function decide(int x,int y,int z) which checks and prints whether the triangle is equilateral,isosceles or scalene.   
Functions and Methods
Functions and Methods  (1) Write a program in java to input 10 numbers. Use a function to find and print the cube of each number. (2) Write a program in java to input day number. Use a function daysofweek(int dysno) to accept
static functions
2. Static Functions 3. Instance Variable  Static Variables Static... object. Static Methods Static method is the method which belongs to the class... call only other static methods and can not call a non-static method from it. 3
Even and odd functions in java
Even and odd functions in java  Even and odd functions in java  ... have two separate functions for checking either number is even or odd. We are passing number as argument in methods
PHP list class methods
Function get_class_methods gives the all methods names of the given class. It takes input as class name and returns the array of the methods name PHP LIst Class Methods Example <?php class myclass{ function aa
PHP Files management functions and examples.
language provides many functions for the manipulation of files from the PHP program. Here in this section we will learn about all the PHP file functions.  
methods
methods  PrintStream class has two formatting methods,what
methods
methods  PrintStream class has two formatting methods,what
methods
methods  PrintStream class has two formatting methods,what
Call an array from multiple functions
Call an array from multiple functions  I am having two methods in this method i am getting array values from another class. i create same array name for accessing the method values(array) but it will access only one method values
PHP Magic Methods
can not use the magic methods name in any user-defined functions...Magic Methods in PHP: In PHP there are so many methods are included in recent versions, magic methods are one of them. The magic methods are listed below
JSTL Functions
named var. We are going to use the various functions provided to us by the jstl functions library.  The JSTL functions library has many methods. We... JSTL Functions syntax : <%@ taglib prefix = "fn"
PHP Date Examples, PHP Date functions
The PHP Date function provides many options to the PHP programmer. It allows the developers to manipulate PHP Date in easy way. You will find many methods... Tutorials series we will show the usages of PHP Date functions with examples
Stored Procedures and Functions
Stored Procedures and Functions       Stored Routines (Procedures and Functions) are supported...) BEGIN.....END Compound Statement Syntax Stored Procedure or Functions can
Object-Oriented Implementation of Numerical Methods - Java Tutorials
Object-Oriented Implementation of Numerical Methods 2002-04-01 The Java... of Numerical Methods Author: Dr. Heinz M. Kabutz If you are reading... Implementation of Numerical Methods by Dr. Didier Besset As promised, this week I am
What is functions?
What is functions?  Hi, Please tell me about PHP functions? Thanks in advance
What is functions?
What is functions?  Hi, Please tell me about PHP functions? Thanks in advance
What is functions?
What is functions?  Hi, Please tell me about PHP functions? Thanks in advance.   About Functions: Functions in PHP is block of code... functions and use it multiple times. In PHP there is many pre-defined functions
Inbuild functions
Inbuild functions  List all the inbuild functions in java
Methods of HttpServlet
Methods of HttpServlet  What are methods of HttpServlet
PHP Functions, PHP Functions Tutorials
PHP Functions In this section we will understand important PHP functions with the help of example code. What is Functions? Function is a block of code...; } Functions in PHP PHP provides many built-in functions to do the real job
Boolean functions in JavaScript
Boolean functions in JavaScript  Explain about the Boolean functions present in Javascript
What are encryption functions in PHP?
What are encryption functions in PHP?  What are encryption functions in PHP
decodeURI() and encodeURI() functions in JavaScript
decodeURI() and encodeURI() functions in JavaScript  What are decodeURI() and encodeURI() functions in JavaScript
functions strstr() and stristr().
functions strstr() and stristr().  What is the functionality of the functions strstr() and stristr
the functions unlink and unset
the functions unlink and unset  What is the difference between the functions unlink and unset
Boolean functions present in Javascript
Boolean functions present in Javascript   Explain about the Boolean functions present in Javascript
static methods
static methods  why static methods cannot read or write the instance variables
php stream functions
php stream functions  what does php stream functions do
JavaScript Variadic functions
JavaScript Variadic functions  Explain about Variadic functions
php array functions
php array functions  php array functions list
Agile methods
Agile methods   Why use Agile methods?   This methods focus on shorter iterations, in which the software is brought to a releasable level of quality fairly often, usually somewhere between weekly and monthly. Short
What is Character Functions
What is Character Functions  What is Character Functions   Hi, Here is the answer, Character Functions are INITCAP, UPPER, LOWER, SUBSTR & LENGTH. Additional functions are GREATEST & LEAST. Group Functions
native methods
native methods  what is native methods in java?   A native method is a method that is implemented in a language other than Java. The Java native method is a great way to gain and merge the power of C or C++ programming
c-language pointer functions
c-language pointer functions  what is the execution process of character pointer functions with example
Confusion on Functions. Help Please?!
Confusion on Functions. Help Please?!  Write a program which has a number of functions for getting the area i.e. area of circle, area of square, area of rectangle and area of cylinder. Right, I've got some of it, but I'm just
php oop functions
php oop functions  Just a quick question... php oop functions. can i call the main class function from an instantiated object of the child class
without using built-in functions
without using built-in functions  Hai sir... Please help me to solve this... Findout occurances of each string in every another string (built - in functions are not at all allowed) all, and, sand, falling wall and sand
all c library functions
all c library functions  hi dear c coders, i need all c library functions with a detailed explanation. Who can give me usefull link? thanks beforehand!   Hi Friend, Please go through the following link: C Tutorials
Inverse of trigonometric functions in java.
Inverse of trigonometric functions in java.  How to get inverse of trigonometric functions in java?   public class InverseTrigno... Trigonometric functions are sin, cos and tan. Inverse of these functions
Aggregate Functions
Aggregate Functions       In this section we are going to illustrate aggregate function, with the help of which we can use many arithmetic operation like average, count, maximum
WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?
WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR()?  WHAT IS THE FUNCTIONALITY OF THE FUNCTIONS STRSTR() AND STRISTR
What are the different functions in sorting an array?
What are the different functions in sorting an array?  What are the different functions in sorting an array
Math Constants and Functions using JavaScript
Math Constants and Functions using JavaScript  What's Math Constants and Functions using JavaScript

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.