Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve Part E public class smallfact3 { public static void main(String[] args) { Scanner input = new Scanner (System.in); Scanner input2 = new Scanner (System.in);

Solve Part E

image text in transcribed

public class smallfact3 { public static void main(String[] args) { Scanner input = new Scanner (System.in); Scanner input2 = new Scanner (System.in); Scanner input3 = new Scanner (System.in); System.out.println ("Enter 1 to 6 for char, short, int, long, float, and double"); int number = input.nextInt(); System.out.println ("Enter integer n to calculate hihgest power of m^n"); int n = input2.nextInt(); System.out.println ("Enter integer m to calculate m^n"); int m = input3.nextInt(); // int n = 20; byte cfact = 1; short sfact = 1; int fact = 1; long lfact = 1; float ffact = 1; double dfact = 1.0; for (int i = 1; i   Compute powers of 3 using different tools and calculator (34%) 3. (34%) Here the number 3^100 = 3100 (3 to the 100 power, or 3*3*3... 100 times) is calculated using calculator from Windows 10: 3 4 100- 5.1537752073201133103646112976562e+47 (a) (8%) From the output (the power e+47) and the number of digits after the decimal point, can you conclude that the calculator uses which of the following data types: short, int, long, float, double, or none of them? Explain! (6) (10%) Smallfact3.java on Blackboard calculates the powers of a certain integer (you can use that to calculate the powers of 3. Also you can write your own code). Does 3^100 overflow in the float data type? Why? If so, at which integer n = 100 does overflow happen first. Display your result of 3(n-2), 3-(n-1), and 3n (so if at n=65 you get overflow, then display 3463, 3-64, and 3*65). c) (8%) Repeat (b) for double data type (d) (8%) Repeat (b) for long data type. (e) (e (26%) Repeat Q3 for 24100 = 2100 (2 to the 100th power, or 2*2*2... 100 times. Note every part (a), (b), (c)(d) is 2 points less than Q3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions