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
Thanks sincerely,
Scott
![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:
<terminated> 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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1fa30329-d231-4700-8299-bfc8e385de93%2F11defcf7-6519-419a-888a-078d27c2b6ff%2Fa5nhobl.png&w=3840&q=75)
Transcribed Image Text: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:
<terminated> 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](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1fa30329-d231-4700-8299-bfc8e385de93%2F11defcf7-6519-419a-888a-078d27c2b6ff%2Furfsgkc.png&w=3840&q=75)
Transcribed Image Text: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
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.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