Found 7442 Articles for Java

Java program to convert character to string

Samual Sam
Updated on 21-Oct-2024 11:05:42

696 Views

In this article, we will learn to take a character input from the user and convert it into a string using Java. The toString() method of the Character class converts the character to a string. Problem Statement Write a program in Java to convert a character to a string. Input Enter a character :: T Output T Steps to convert character to string Following are the steps to convert characters to the string − We will start by importing the Scanner class to handle user input using java.util package. After that, ask ... Read More

Java program to convert character to string

Samual Sam
Updated on 21-Oct-2024 11:05:42

696 Views

In this article, we will learn to take a character input from the user and convert it into a string using Java. The toString() method of the Character class converts the character to a string. Problem Statement Write a program in Java to convert a character to a string. Input Enter a character :: T Output T Steps to convert character to string Following are the steps to convert characters to the string − We will start by importing the Scanner class to handle user input using java.util package. After that, ask ... Read More

Java program to calculate the percentage

Lakshmi Srinivas
Updated on 14-Jun-2024 13:37:08

39K+ Views

Percent means percent (hundreds), i.e., a ratio of the parts out of 100. The symbol of a percent is %. We generally count the percentage of marks obtained, return on investment etc. The percentage can go beyond 100% also.For Example, assuming that we have total and a part. So we say what part is what percent of total and should be calculated as −percentage = ( part / total ) × 100AlgorithmBelow is the algorithm to calculate percentage in Java:1. Collect values for part and total 2. Apply formula { percentage = ( part / total ) × 100 } ... Read More

Java program to calculate the percentage

Lakshmi Srinivas
Updated on 14-Jun-2024 13:37:08

39K+ Views

Percent means percent (hundreds), i.e., a ratio of the parts out of 100. The symbol of a percent is %. We generally count the percentage of marks obtained, return on investment etc. The percentage can go beyond 100% also.For Example, assuming that we have total and a part. So we say what part is what percent of total and should be calculated as −percentage = ( part / total ) × 100AlgorithmBelow is the algorithm to calculate percentage in Java:1. Collect values for part and total 2. Apply formula { percentage = ( part / total ) × 100 } ... Read More

Java program to calculate mean of given numbers

Ankith Reddy
Updated on 19-Jun-2020 14:54:39

6K+ Views

Mean is an average value of given set of numbers. It is calculated similarly to that of the average value. Adding all given number together and then dividing them by the total number of values produces mean.For Example Mean of 3, 5, 2, 7, 3 is (3 + 5 + 2 + 7 + 3) / 5 = 4AlgorithmTake an integer set A of n values.Add all values of A together.Divide result of Step 2 by n.The result is mean of A's values.Programpublic class CaculatingMean {    public static void main(String args[]){       float mean;       int ... Read More

Java program to calculate mean of given numbers

Ankith Reddy
Updated on 19-Jun-2020 14:54:39

6K+ Views

Mean is an average value of given set of numbers. It is calculated similarly to that of the average value. Adding all given number together and then dividing them by the total number of values produces mean.For Example Mean of 3, 5, 2, 7, 3 is (3 + 5 + 2 + 7 + 3) / 5 = 4AlgorithmTake an integer set A of n values.Add all values of A together.Divide result of Step 2 by n.The result is mean of A's values.Programpublic class CaculatingMean {    public static void main(String args[]){       float mean;       int ... Read More

Java program to calculate the average of numbers in Java

karthikeya Boyini
Updated on 13-Mar-2020 11:17:58

18K+ Views

An average of a set of numbers is their sum divided by their quantity. It can be defined as −average = sum of all values / number of valuesHere we shall learn how to programmatically calculate average.Algorithm1. Collect integer values in an array A of size N. 2. Add all values of A. 3. Divide the output of Step 2 with N. 4. Display the output of Step 3 as average.ExampleLive Demopublic class AverageOfNNumbers {    public static void main(String args[]){       int i,total;       int a[] = {0,6,9,2,7};       int n = 5;       total = 0;       for(i=0; i

Java program to calculate the average of numbers in Java

karthikeya Boyini
Updated on 13-Mar-2020 11:17:58

18K+ Views

An average of a set of numbers is their sum divided by their quantity. It can be defined as −average = sum of all values / number of valuesHere we shall learn how to programmatically calculate average.Algorithm1. Collect integer values in an array A of size N. 2. Add all values of A. 3. Divide the output of Step 2 with N. 4. Display the output of Step 3 as average.ExampleLive Demopublic class AverageOfNNumbers {    public static void main(String args[]){       int i,total;       int a[] = {0,6,9,2,7};       int n = 5;       total = 0;       for(i=0; i

Java program to find the cube root of a given number

George John
Updated on 19-Jun-2020 14:51:46

2K+ Views

Following is an example to find the cube root of a given number.Programimport java.util.Scanner; public class FindingCubeRoot {    public static void main(String args[]){       double i, precision = 0.000001;       System.out.println("Enter a number ::");       Scanner sc = new Scanner(System.in);       int num = sc.nextInt();       for(i = 1; (i*i*i)

Java program to find the cube root of a given number

George John
Updated on 19-Jun-2020 14:51:46

2K+ Views

Following is an example to find the cube root of a given number.Programimport java.util.Scanner; public class FindingCubeRoot {    public static void main(String args[]){       double i, precision = 0.000001;       System.out.println("Enter a number ::");       Scanner sc = new Scanner(System.in);       int num = sc.nextInt();       for(i = 1; (i*i*i)

Advertisements