CS 170: Java Programming 1 PART C: Powerof2 Write a program with class name PowerOf2 that computes all powers of 2 from 20 up to 220. Sample Output: PowerOf2 [Java Application] /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Conter 2 to the 0 equals 1.0 2 to the 1 equals 2.0 2 to the 2 equals 4.0 2 to the 3 equals 8.0 2 to the 4 equals 16.0 2 to the 5 equals 32.0 2 to the 6 equals 64.0 2 to the 7 equals 128.0 2 to the 8 equals 256.0 2 to the 9 equals 512.0 2 to the 10 equals 1024.0 2 to the 11 equals 2048.0 2 to the 12 equals 4096.0 2 to the 13 equals 8192.0 2 to the 14 equals 16384.0 2 to the 15 equals 32768.0 2 to the 16 equals 65536.0 2 to the 17 equals 131072.0 2 to the 18 equals 262144.0 2 to the 19 equals 524288.0 2 to the 20 equals 1048576.0 Compile Undo Cut Copy Paste Find... Close Source Code /** * Scott Elliott * CS A170 * March 6, 2020 * Exercise 13 */ import java.util.Scanner; public class Powerof2 public static void main(String[] args) { double i = 20, power = 20, value = while(i <= 220) Math.pow(2, power); System.out.print("2 to the + power + equals + value + \n"); power += 1; value = Math.pow(2, power); i++; BlueJ: Terminal Window - A170_E13_Elliott_Scott Options 2 to the 22.0 equals 4194304.0 2 to the 23.0 equals 8388608.0 2 to the 24.0 equals 1.6777216E7 2 to the 25.0 equals 3.3554432E7 2 to the 26.0 equals 6.7108864E7 2 to the 27.0 equals 1.34217728E8 2 to the 28.0 equals 2.68435456E8 2 to the 29.0 equals 5.36870912E8 2 to the 30.0 equals 1.073741824E9 2 to the 31.0 equals 2.147483648E9 2 to the 32.0 equals 4.294967296E9 2 to the 33.0 equals 8.589934592E9 2 to the 34.0 equals 1.7179869184E10 2 to the 35.0 equals 3.4359738368E10 2 to the 36.0 equals 6.8719476736E10 2 to the 37.0 equals 1.37438953472E11 2 to the 38.0 equals 2.74877906944E11 2 to the 39.0 equals 5.49755813888E11 Can only enter input while your programming is running
CS 170: Java Programming 1 PART C: Powerof2 Write a program with class name PowerOf2 that computes all powers of 2 from 20 up to 220. Sample Output: PowerOf2 [Java Application] /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Conter 2 to the 0 equals 1.0 2 to the 1 equals 2.0 2 to the 2 equals 4.0 2 to the 3 equals 8.0 2 to the 4 equals 16.0 2 to the 5 equals 32.0 2 to the 6 equals 64.0 2 to the 7 equals 128.0 2 to the 8 equals 256.0 2 to the 9 equals 512.0 2 to the 10 equals 1024.0 2 to the 11 equals 2048.0 2 to the 12 equals 4096.0 2 to the 13 equals 8192.0 2 to the 14 equals 16384.0 2 to the 15 equals 32768.0 2 to the 16 equals 65536.0 2 to the 17 equals 131072.0 2 to the 18 equals 262144.0 2 to the 19 equals 524288.0 2 to the 20 equals 1048576.0 Compile Undo Cut Copy Paste Find... Close Source Code /** * Scott Elliott * CS A170 * March 6, 2020 * Exercise 13 */ import java.util.Scanner; public class Powerof2 public static void main(String[] args) { double i = 20, power = 20, value = while(i <= 220) Math.pow(2, power); System.out.print("2 to the + power + equals + value + \n"); power += 1; value = Math.pow(2, power); i++; BlueJ: Terminal Window - A170_E13_Elliott_Scott Options 2 to the 22.0 equals 4194304.0 2 to the 23.0 equals 8388608.0 2 to the 24.0 equals 1.6777216E7 2 to the 25.0 equals 3.3554432E7 2 to the 26.0 equals 6.7108864E7 2 to the 27.0 equals 1.34217728E8 2 to the 28.0 equals 2.68435456E8 2 to the 29.0 equals 5.36870912E8 2 to the 30.0 equals 1.073741824E9 2 to the 31.0 equals 2.147483648E9 2 to the 32.0 equals 4.294967296E9 2 to the 33.0 equals 8.589934592E9 2 to the 34.0 equals 1.7179869184E10 2 to the 35.0 equals 3.4359738368E10 2 to the 36.0 equals 6.8719476736E10 2 to the 37.0 equals 1.37438953472E11 2 to the 38.0 equals 2.74877906944E11 2 to the 39.0 equals 5.49755813888E11 Can only enter input while your programming is running
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
Hello bartleby staff,
Here is the problem, and the answer program I have written thus far with it's output. Why is the starting output with the exponent set to a power of 22 and how do I fix it so that it is set to a power of 20 at the start of the output?
Thanks sincerely,
Scott
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education