Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
test1
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.text.DecimalFormat; class Rextester { public static void main(String args[]) { // Instancia Objeto Calculadora Calc = new Calculadora(); DecimalFormat doisDigitos = new DecimalFormat("###,##0.000"); // Chamada de Métodos System.out.println("total da soma = "+Calc.Soma( 5, 10 )); System.out.println("total da subtração = "+Calc.Subtracao(5, 10)); System.out.println("total da multiplicação = "+Calc.Multiplicacao(5, 10)); System.out.println("Area = "+(doisDigitos.format(Calc.Area(3.1415, 5.00)))); System.out.println("Area = "+(doisDigitos.format(Calc.Lado(3.1415, 5.00)))); } } class Calculadora { // Métodos public int Soma(int num_1, int num_2) { return(num_1 + num_2); } public int Subtracao( int num_1, int num_2 ) { if( num_1 > num_2 ) return(num_1 - num_2); return( num_2 - num_1 ); } public int Multiplicacao( int num_1, int num_2 ) { return(num_1 * num_2); } public double Area( double num_1, double num_2 ) { return(num_1 * num_2 * num_2); } public double Lado( double num_1, double num_2 ) { return(num_1 * num_2); } }
[
+
]
Show input
Compilation time: 0.84 sec, absolute running time: 0.15 sec, cpu time: 0.14 sec, memory peak: 20 Mb, absolute service time: 0,99 sec
edit mode
|
history
|
discussion
total da soma = 15 total da subtração = 5 total da multiplicação = 50 Area = 78.538 Area = 15.708