Question

Use Java programming language Float calculations: Initially, declare a float variable and give it the initial...

Use Java programming language

Float calculations:

Initially, declare a float variable and give it the initial value 3.0.

float number = 3.0f;

Now, multiply the number by 10 and print out the value, using default precision as shown.

number *= 10.0;
System.out.println(number);

Repeat this 20 times. ( use a loop. You will find it helpful if you print out both the new value of number and the iteration. So, iteration 1 prints out 30.0; iteration 2 prints out 300.0, etc.)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public class FloatOperations {

    public static void main(String[] args) {
        float number = 3.0f;
        for (int i = 0; i < 20; i++) {
            number *= 10.0;
            System.out.println(number);
        }
    }
}
Add a comment
Know the answer?
Add Answer to:
Use Java programming language Float calculations: Initially, declare a float variable and give it the initial...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write code in Java programming language. The ShoppingCart class will be composed with an array of...

    Write code in Java programming language. The ShoppingCart class will be composed with an array of Item objects. You do not need to implement the Item class for this question, only use it. Item has a getPrice() method that returns a float and a one-argument constructor that takes a float that specifies the price. The ShoppingCart class should have: Constructors: A no-argument and a single argument that takes an array of Items. Fields: • Items: an array of Item objects...

  • C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array...

    C Programming Language 2(a) Define a struct with 1 int array named i, 1 float array named f, and one double array named d, each of size M. (b)Declare array x with N of those structs. (c)Write a void function to traverse array x (using a pointer) assigning to each element in each array d (in each struct in array x) the sum of the corresponding elements in arrays i and f (in the same struct). Use 3 pointers (of...

  • In this problem you'll get to use one of Java's random number generators, java.util.Random (see the...

    In this problem you'll get to use one of Java's random number generators, java.util.Random (see the docs for Random). This class generates a random double precision number uniformly distributed in the range [0.0 ... 1.0). That is, the numbers go from 0 to 1, including 0 but excluding 1. It is a common need in Java programming to generate a random integer number that's uniformly distributed in the range of [0 ... n), such as we saw in the dice...

  • Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What...

    Please complete the following programming with clear explanations. Thanks! Homework 1 – Programming with Java: What This Assignment Is About? Classes (methods and attributes) • Objects Arrays of Primitive Values Arrays of Objects Recursion for and if Statements Selection Sort    Use the following Guidelines: Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use upper case for constants. • Use title case (first letter is upper case) for classes. Use lower case with uppercase...

  • ** Use Java programming language Program the following algorithms in JAVA: A. Classical matrix multiplication B....

    ** Use Java programming language Program the following algorithms in JAVA: A. Classical matrix multiplication B. Divide-and-conquer matrix multiplication In order to obtain more accurate results, the algorithms should be tested with the same matrices of different sizes many times. The total time spent is then divided by the number of times the algorithm is performed to obtain the time taken to solve the given instance. For example, you randomly generate 1000 sets of input data for size_of_n=16. For each...

  • In java The Java language has a math class with several methods you can use for...

    In java The Java language has a math class with several methods you can use for mathematical calculations. For instance, to find the square root of a number you can use the Math.sqrt method: double value = 9.0; double result = Math.sqrt(value); In the above example the variable result will hold 3.0. The same holds true for the cube root: double value = 9.0; double result = Math.cbrt(value); You can also get the base 10 logarithm of a number: double...

  • JAVA PROGRAMMING It is a well-researched fact that men in a restroom generally prefer to maximize...

    JAVA PROGRAMMING It is a well-researched fact that men in a restroom generally prefer to maximize their distance from already occupied stalls, by occupying the middle of the longest sequence of unoccupied places. For example, consider the situation where ten stalls are empty. _ _ _ _ _ _ _ _ _ _    The first visitor will occupy a middle position: _ _ _ _ _ X _ _ _ _   The next visitor will be in the middle...

  • You have to use Binary Tree ADT. Problem Use Java as Programming Language Define an ESports...

    You have to use Binary Tree ADT. Problem Use Java as Programming Language Define an ESports World Cup class that implements the E-Games World Cup using a Binary Tree ADT. The external nodes of the tree correspond to each competing player. The internal nodes correspond to games played at different rounds of the cup (i.e. root of the tree is the final game, its children are the semifinals, etc.). Two players compete against each other and the winner goes to...

  • PLEASE ANSWER #5AND #6, THE ANSWER FOR #3 AND #4 ARE ALREADY PROVIDED!!! 3 .Using Java,...

    PLEASE ANSWER #5AND #6, THE ANSWER FOR #3 AND #4 ARE ALREADY PROVIDED!!! 3 .Using Java, Write a computer program that prompts the user for one number, n for the number of items in the array to sort, and create and sort 1000 arrays of this size timing the run to get an average time to sort an array of this size. Then do the following: Initiate a variable running_time to 0 Create a for loop that iterates 1000 times....

  • This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This...

    This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This program will use the ArrayManager class. The final version of the program is described below, but initially use it to test your ArrayManager class as you write it. Complete the ArrayManager class as specified below: The class will have exactly two instance variables:  An array of integers  A count of the number of elements currently in the array The class will have...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT