Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this is java language 0.2 Suppose we have the following: int a = 37, b = 5; System.out.println (a - a/b*b-a % b); Hypothesize what

this is java language
image text in transcribed
image text in transcribed
0.2 Suppose we have the following: int a = 37, b = 5; System.out.println (a - a/b*b-a % b); Hypothesize what the output will be. Test your hypothesis by executing a small program that includes that code. Can you find another pair of positive int values for a and b that will produce different output? Explain. 0.3 Hypothesize the output from the following: System.out.println (1/0); System.out.println (1.0/0); Test your hypotheses by executing a small program that includes that code. 0.4 In the String class, read the specification for the indexOf method that takes a String parameter. Then hypothesize the output from the following System.out.println ("The snow is now on the ground.".indexOf("now")); Test your hypothesis by executing a small program that includes that code. 0.5 In the String class, read the specification for the indexOf method that takes a String parameter and an int parameter. Then hypothesize the output from the following System.out.println ("The snow is now on the ground.".indexOf("now", 8)); Test your hypothesis by executing a small program that includes that code. Page 26 09 Study the following method: public void mystery (int n) { System.out.print ("For n =" + n); while (n > 1) if (n % 2 == 0) n=n/2; else n=3n+ 1; System.out.println (", the loop terminated."); } // method mystery Trace the execution of this method when n = 7. In the same class as the method mystery, develop a main method and a run method to show that the while statement in the method mystery successfully terminates for any positive integer n less than 100. Cultural note: It can be shown that this method terminates for all int values greater than 0, but it is an open question whether the method terminates for all integer values greater than 0

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

Step: 3

blur-text-image

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

How can I become a more effective listener?

Answered: 1 week ago