What is cube?Cube is a three-dimensional object with six faces of square shape which means it has sides of same length and breadth. Cube is the only regular hexahedron with following properties −six faces12 edges8 verticesGiven below is the figure of cubeProblemGiven with the side, the task is to find the total surface area and volume of a cube where surface area is the space occupied by the faces and volume is the space that a shape can contain.To calculate surface area and volume of a cube there is a formula −Surface Area = 6*Side*sideVolume = Side*side*sideExampleInput-: side=3 Output-: volume ... Read More
What is Octahedron?The word ‘dodecahedron’ is derived from the Greek words where, Octa means ‘Eight’ and hedron specifies ‘faces’. octahedron in geometric is a 3-D platonic or regular solid with eight faces. Like, other figures octahedrons also have properties and that are −6 polyhedron vertices12 polyhedron edges8 equilateral facesGiven below is the figure of octahedronProblemGiven with the sides, the program must find the surface area of octahedron where surface area is the total space occupied by the faces of the given figure.To calculate surface area of octahedron there is a formula −Where, a is side of an OctahedronExampleInput-: side=5 Output-: ... Read More
What is Dodecahedron?The word ‘dodecahedron’ is derived from the Greek words where, dodeca means ‘twelve’ and hedron specifies ‘faces’. Dodecahedron in geometric is a 3-D platonic or regular solid with twelve flat faces. Like, other figures dodecahedron also have properties and those are −20 polyhedron vertices30 polyhedron edges12 pentagonal faces, as a pentagon is a five-sided polygonGiven below is the figure of dodecahedronProblemGiven with an edge, the program must find the surface area of dodecahedron where surface area is the total space occupied by the faces of the given figure.To calculate surface area of dodecahedron there is a formula −ExampleInput-: ... Read More
Given with the number n the task is to calculate the factorial of a number. Factorial of a number is calculated by multiplying the number with its smallest or equal integer values.Factorial is calculated as −0! = 1 1! = 1 2! = 2X1 = 2 3! = 3X2X1 = 6 4! = 4X3X2X1= 24 5! = 5X4X3X2X1 = 120 . . . N! = n * (n-1) * (n-2) * . . . . . . . . . .*1ExampleInput 1 -: n=5 Output : 120 Input 2 -: n=6 Output : 720There are multiple methods that ... Read More
Given with certain values the program will develop an EMI calculator to generate the needed output. EMI stands for Equated Monthly Installment. So this calculator will generate monthly EMI amount for the user.ExampleInput-: principal = 2000 rate = 5 time = 4 Output-: Monthly EMI is= 46.058037The formula used in the below program is −EMI : (P*R*(1+R)T)/(((1+R)T)-1)where, P indicates loan amount or the Principal amount.R indicates interest rate per monthT indicates loan time period in yearApproach used below is as followsInput principal, rate of interest and time in float variableApply the formula to calculate the EMI amountPrint the ... Read More
The StringTokenizer class allows an application to break a string into tokens. Following are the methods −Sr.NoMethod & Description1int countTokens()This method calculates the number of times that this tokenizer's nextToken method can be called before it generates an exception.2boolean hasMoreElements()This method returns the same value as the hasMoreTokens method.3boolean hasMoreTokens()This method tests if there are more tokens available from this tokenizer's string.4Object nextElement()This method returns the same value as the nextToken method, except that its declared return value is Object rather than String.5String nextToken()This method returns the next token from this string tokenizer.6String nextToken(String delim)This method returns the next token in this ... Read More
The HTML DOM Textarea autofocus property returns and modify whether the text area should automatically get focused or not when the page loads.SyntaxFollowing is the syntax −1. Returning autofocusobject.autofocus2. Modifying autofocusobject.autofocus = true | falseLet us see an example of HTML DOM Textarea autofocus Property:Example body { color: #000; height: 100vh; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; ... Read More
To traverse through a HashMap, use Iterator. The HashMap class uses a hashtable to implement the Map interface. This allows the execution time of basic operations, such as get( ) and put( ), to remain constant even for large sets.Following is the code to traverse through a HashMap −Exampleimport java.util.*; public class Main { public static void main(String args[]) { HashMap hashMap = new HashMap(); hashMap.put("John", new Integer(10000)); hashMap.put("Tim", new Integer(25000)); hashMap.put("Adam", new Integer(15000)); hashMap.put("Katie", new Integer(30000)); hashMap.put("Jacob", new Integer(45000)); ... Read More
The new operator is used in Java to create new objects. It can also be used to create an array object.Let us first see the steps when creating an object from a class −Declaration − A variable declaration with a variable name with an object type.Instantiation − The 'new' keyword is used to create the object.Initialization − The 'new' keyword is followed by a call to a constructor. This call initializes the new object.Now, let us see an example −Examplepublic class Puppy { public Puppy(String name) { // This constructor has one parameter, name. ... Read More
The HTML DOM Textarea defaultValue property returns and modify the value of name attribute of a text area element in an HTML document.SyntaxFollowing is the syntax −1. Returning nameobject.name2. Adding nameobject.name = “text”Let us see an example of HTML DOM Textarea name Property:Example body { color: #000; background: lightseagreen; height: 100vh; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; ... Read More