Method called printpowersof2 that accepts a maximum number

Assignment Help JAVA Programming
Reference no: EM13161726

Write a method called printPowersOf2 that accepts a maximum number as an argument and prints each power of 2 from 20 (1) up to that maximum power, inclusive. For example, consider the following calls: printPowersOf2(3); printPowersOf2(10); These calls should produce the following output: 1 2 4 8 1 2 4 8 16 32 64 128 256 512 1024 You may assume that the value passed to printPowersOf2 is 0 or greater. (The Math class may help you with this problem. If you use it, you may need to cast its results from double to int so that you don't see a .0 after each number in your output. Also, can you write this program without using the Math class?)

Reference no: EM13161726

Questions Cloud

20 integers saved in a file called "data.txt" : There are 20 integers saved in a file called "data.txt" (just a random txt file with some numbers) All integers are in the range from 1 to 10
All the new strings generated : Explain why, if on some round, all the new strings generated for any syntactic category are longer than s, and s has not already been generated for L(), then s cannot ever be put in L(). Hint: Use Exercise 11.3.5.
Brownian motion is a physical phenomenon : Brownian motion is a physical phenomenon which can be observed, for instance, when a small particle is immersed in a liquid.
Write a program code to compute and build a table of reynold : Write a program code to compute and build a table of Reynolds numbers at flow velocities varying from 100 to 1000 ft/sec (at increments of 100)
Method called printpowersof2 that accepts a maximum number : Write a method called printPowersOf2 that accepts a maximum number as an argument and prints each power of 2 from 20 (1) up to that maximum power, inclusive. For example, consider the following calls: printPowersOf2(3); printPowersOf2(10)
Create a class named gamer that has a field for name : Create a class named Gamer that has a field for name(string) and a field for points(int).
Federal government regulates labels : The federal government regulates labels, warranties, and consumer products. Without government regulation, what abuses are likely to occur?
Determine the current flows : given an electrical circuit which consists of resistor and voltage sources, determine the current flows (i1,i2,i3, and i4) use the following values for the voltage and resistor sources: V1=20 volts V2=12 volts V3=40 volts, R1= 18 ohms R2= 10 ohms R3=..
Method named printgrid : Write a method named printGrid that accepts two integer parameters rows and cols. The output is a comma-separated grid of numbers where the first parameter (rows) represents the number of rows of the grid and the second parameter (cols) represents th..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Develop java applet that will help elementary school student

Develop a Java applet that will help an elementary school student learn multiplication. Use the Math.random method or a Random object to produce two positive one-digit integers.

  Create a bar chart that illustrates sales.

Hal's Used Cars has four salespeople named Pam, Leo, Kim, and Bob. Accept values for the number of cars sold by each salesperson in a month, and create a bar chart that illustrates sales. Save the file as BarGraph.java.

  Alter the prototype form page by javascript function

Alter the prototype form page so that when JavaScript function has verified that all the required fields have been filled, cookie is added to user's computer.

  Create online store web site

the Java and JSP source codes and SQL scripts for creating a database in Oracle - any configuration files used

  Please write the code in java

Please write the code in java for  Recursion,  Sorting and Searching

  The drink machine should have a supply

When the applet starts, the drink machine should have a supply of 20 of each of the drinks. The applet should have a text field where the user can enter the amount of money he or she is giving the machine. The user can then click on a button to selec..

  Write java programming to show number of credits for course

Write the java programming to solve following problem. We are given a student's marks in Calculus 1, CS1, and Physics 1 (each mark being between 0 and 100) also number of credits for each course.

  Write down the java code for the bank

Write down the java code for the bank of Fraud. User is presented with menu which looks something like this: 1. Deposit 2. Withdrawal 3. Check Balance 4. Exit.

  Java program simulate a network

Java program simulate a network

  Create web application uses visual web java server

Create the Web application which uses Visual Web Java Server Faces framework and either Apache Tomcat or Glassfish as the server.

  Write a program that shows the current time and date

Write a program that shows the current time and date

  Implement bounded partial queue by using signaling mechanism

Implement the same using a signaling mechanism that signals to all waiting dequeuers and do a performance comparison using timing analysis. Which works faster?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd