All Matches
Solution Library
Expert Answer
Textbooks
Search Textbook questions, tutors and Books
Oops, something went wrong!
Change your search query and then try again
Toggle navigation
FREE Trial
S
Books
FREE
Tutors
Study Help
Expert Questions
Accounting
General Management
Mathematics
Finance
Organizational Behaviour
Law
Physics
Operating System
Management Leadership
Sociology
Programming
Marketing
Database
Computer Network
Economics
Textbooks Solutions
Accounting
Managerial Accounting
Management Leadership
Cost Accounting
Statistics
Business Law
Corporate Finance
Finance
Economics
Auditing
Hire a Tutor
AI Study Help
New
Search
Search
Sign In
Register
study help
computer science
introduction java program
Questions and Answers of
Introduction Java Program
Write a complete program to prompt for and input a number, and then compute 2 to the power of the number that was input. The form of the input and output can be found below, and as always be careful
Repeat the previous exercise using dialog boxes. Examples of input and output dialog boxes are shown below: Input ? Message Enter the number: 4.0 OK Cancel Two to the power of 4.0 is 16.0. OK X X
Answer the questions A-D about the following declaration of class Circle:*A. Declare and create a variable of type Circle called innerCircle.B. Write a statement using the setRadius method to change
Write a complete program to calculate the volumes of a cone and a hollow cylinder. The shape of a hollow cylinder is shown below, where \(r\) is the radius of the inner cylinder and \(R\) is the
Repeat the previous exercise using dialog boxes for input ajnd output.
Repeat the previous exercise using a case structure instead of a selection structure.Data From Exercise 12 Repeat the previous exercise using a case structure instead of a selection structure.
Write a program that reads the three numbers from the file created in the previous exercise. After the data are read, display the smallest and the largest of the three numbers.
Would it help to place the section where each processor prints "Hello World" in Fig. 12.2 in the critical section? If so why and if not, why not?
Plot execution times of several runs of the complete program shown in Fig. 12.6 with a different number of threads and see the speed up.
Indicate whether the following statements are syntactically correct or incorrect. If incorrect, indicate what is wrong with the statement:A. integer num1, num2;B. double num3;C. 7.8 = num 3; Assume
Assume the following declaration and initialization of variables:int i, j;double d;i \(=1\);\(j=5 ;\)\(\mathrm{d}=2.34 ;\)Determine the value for each of the following expressions, or explain why it
Assuming the following declaration and initialization of variables,Determine the value assigned to the variable in each of the following assignment statements, or explain why it is not a valid
Implement each of the following statements in the Java language:A. Declare a variable weight of type double.B. Declare a constant EULER_NUMBER of type double and assign it the value 2.7182 .
Given the following Java program, what will be output to the screen? Be sure to line everything up properly. Use an underscore to represent a blank and the words blank line to represent a blank line:
Write code to output the following pattern: ** ** ** * * **** * ** **
After the following statements are executed, what is stored in value1, value2, and value3? 5; int value2 = 9; int value3 = 4; valuel value2; value2= value3; value3 valuel; int valuel = =
Write an equivalent Java assignment statement for each of these mathematical expressions.A. \(v=\frac{49 x^{15}}{y+z}\)B. \(s=r \pi \sqrt{r^{2}+h^{2}}\)C. \(a=\frac{\sin g}{c}\)
Rewrite the complete program in Sect. 1.10 using dialog boxes for input and output. Input ? Message Enter the number: 4.0 OK Cancel Two to the power of 4.0 is 16.0. OK X X
Indicate whether the following statements using the Circle class in Fig. 2.34 in Sect. 2.11 are syntactically correct or incorrect. If incorrect, indicate what is wrong with the statement: *A. Circle
Draw contour diagrams to show the state of execution prior to the following line numbers of the CalcAreaCircle class in Fig. 2.35 in Sect. 2.11.A. Line 8B. Line 12 (assume an input value of 2.0 ) //
Draw contour diagrams to show the state of execution prior to Line 8 of the Invoke class in Fig. 2.21 in Sect. 2.9. class Invoke { public static void main(String[] args) { } heged class Number (
Draw contour diagrams to show the state of execution prior to Line 11 of the class Multiple shown in Fig. 2.27 in Sect. 2.9. class Multiple public static void main (String[] args) { } } } class
Given the code segment below, indicate the output for the following initial values of \(y\) :A. What is the output if the integer variable y contains 10 ?B. What is the output if the integer variable
Given the code segment below, indicate the output for the following initial values of \(x\) and \(y\) :A. What is the output if the integer variable \(x\) contains 10 and \(y\) contains -15 ?B. What
Given the code segment below, indicate the output for the following initial values of \(\mathrm{x}, \mathrm{y}\), and \(\mathrm{z}\) :A. What is the output if the integer variable \(x\) contains \(1,
Declare a Boolean variable, isEligible, and assign it a value of false.
Evaluate each Boolean expression as true or false. Show intermediate steps. Assume int num1 = 5, int num2 \(=-2\), int num3 \(=0\), boolean flag1 = true, and boolean flag2 = false. *A. numl> num2 ||
Using a truth table, show that the first De Morgan's law discussed in Sect. 3.5 is correct. C FFTT d CFTFT c and d F FFT 1
Using a truth table, show that the second De Morgan's law discussed in Sect. 3.5 is correct. C SFT not c T F
Write a code segment to ask a user to enter a number between 1 and 4 , and print the name of the class (First-Year, Sophomore, Junior, and Senior) corresponding to the number. Use a case structure.
Repeat the previous exercise using a selection structure instead of a case structure.Data From previous exerciseWrite a code segment to ask a user to enter a number between 1 and 4 , and print the
Write a code segment to ask a user to enter a number between 1 and 12 , and print the name of the month corresponding to the number. Use a selection structure.
Repeat the previous exercise using a case structure instead of a selection structure.Data From previous exerciseWrite a code segment to ask a user to enter a number between 1 and 12 , and print the
In Sect. 3.5 it was mentioned that a mathematical expression like \(0
The dew point temperature is a good indicator of how humid it feels during a hot day. The US National Weather Service (NWS) summarizes the human perception of humidity using the dew point
Repeat the previous exercise using a case structure instead of a selection structure.Data From previous ExerciseThe dew point temperature is a good indicator of how humid it feels during a hot day.
Repeat the previous exercise using dialog boxes for input ajnd output.Data From previous exerciseRepeat the previous exercise using a case structure instead of a selection structure.Data From
Write a complete program to compare the temperatures of three different cities and find the hottest city. First, implement a class called Thermometer as described below:A. Thermometer has one private
Identify the syntax errors in the following code segment: int sum, i; sum = 0; i = 0; while (i >= 0); { sum + i; } sum i = 1 + 2;
Identify the syntax errors in the following code segment: int product; product = 1; for (i=1, i
Determine the output from the following code segment: int sum; int count; sum 0; count = 1; while (sum < 10) { } sum sum + count; count++; System.out.println ("sum = System.out.println("count
Determine the output from the following code segment: int sum = 2; int number = 3; do { sum = sum + number; number++; System.out.println("sum " + sum) ; System.out.println ("number = " + number); }
Determine the output from the following code segment: int outer = 1; while (outer < 4) { int inner = 1; while (inner
Determine the output from the following code segment: int i, j; for (i=1; i
Rewrite the following for loop as a A. while loop *B. do-while loop int total, count; total = 0; for (count = 1; count
A store is having a sale and items are either 30,50 , or \(70 \%\) off. Assuming all the items priced between \(\$ 5.00\) and \(\$ 50.00\) are on sale, output the following table using nested loops.
Assuming \(\mathrm{n}\) is input, rewrite the following while loop as a(n)*A. for loopB. If Statement and do-while loop *A. for loop B. if statement and a do-while loop count, n; int total, total
Repeat Exercise 15 in Chap. 3 to allow the user to enter temperatures for any number of cities using the best iteration structure.Data From Exercise 15The dew point temperature is a good indicator of
Repeat Exercise 15 in Chap. 3 to allow the user to find the hottest city for any number of sets of 3 cities. Use input, message, and confirmation dialog boxes. Confirmation dialog boxes are discussed
The Fibonacci sequence is the series of numbers which can be found by adding up the two numbers before it as shown below:\[0,1,1,2,3,5,8,13,21,34, \ldots\]Write a complete program to compute the
Repeat Exercise 12 to allow the user to repeat finding the Fibonacci number for an integer. Use input, message, and confirmation dialog boxes. Confirmation dialog boxes are discussed in Appendix A.6.
Given two numbers, the largest divisor among all the integers that divide the two numbers is known as the greatest common divisor. For example, the positive divisors of 36 are \(1,2,3,4,6,9,12,18\),
The product of the first 5 integer is 120 . Identify the problem with the following code segment and discuss how to fix it. int answer, count, number; count = 0; answer = 0; number = 1; while (count
Identify the valid and invalid overloaded constructors in the following code: public class PointD { private double x; private double y; * // constructor 1 public PointD() { } } // constructor 2
Identify the valid and invalid overloaded methods in the following code: public class PointD { private double x; private double y; // method 1 public double distance (PointD pt) { // method 2 public
A hexahedron is a three-dimensional shape with six faces. In this problem, a class which represents a hexahedron with squares at the top and the bottom as shown below will be implemented.Assume that
Draw contour diagrams to show the state of execution right after the execution of the statement line1=new LineSI (pt1, pt2); in Fig. 5.15 in Sect. 5.6.1. middle PointD pl PointD p2 PointD X y
Draw contour diagrams to show the state of execution right after the execution of the statement card. purchase In Euros(100.00); in Fig. 5.16 in Sect. 5.6.2. // a program to create card, make
Implement a class Rectangle which represents a rectangle shape as described below:A. The Rectangle class has one private class constant DEFAULT_VALUE that should be initialized to 0.0 .B. The
Expand the PointD class discussed in this chapter to include the quadrant information of a point. The x-axis and y-axis divide the plane into four regions called quadrants. The quadrants are labeled
Describe how to differentiate methods with the same name defined in the same class.
Describe the use of the keyword this.
A part of the LineSI class from Section 5.6.1 is shown below. Identify necessary and unnecessary use of the keyword this. public class LineSI { // data members private static final double
Suppose the Vehicle class is defined to keep track of vehicles in a household. What kinds of instance data members, variables and constants, would be defined for such Vehicle objects? Do any useful
Write a complete program for the user to play a number guessing game. The computer generates a random number from 1-10, and the user gets one chance to guess that number. Output a message whether the
Identify the errors in the following code segments: A. String textl; text1=new String (girth); *B. String text2; text2=new Text ("shedding blade"); C. String text3; text3= new Sting ("grazing
Determine the return value for each of these expressions, assuming the following declaration: String org; org = new String ("American Quarter Horse Association"); A. org.substring (5, 8) *B.
Draw contour diagrams to show the state of execution after the execution of the following code segment: String s1, s2, s3, s4; sl = new String("stirrup irons"); s2 "stirrup irons"; new
Determine the output from the following code segment: String star; star int i; for (i=0; i
Write a program that asks the user for a positive integer, receives input as a String, and outputs a string with commas in the appropriate places. For example, if the input is 1000000then the output
Repeat the previous exercise using dialog boxes for input and output. An input dialog box is used to input a positive integer. Then, a message dialog box displays a string with commas in the
Write a program for a given word and string that willa. Check if the word is in the string.b. Count all occurrences of the word in the string.c. Remove all occurrences of the word from the string.
With a given String object called org containing a value "American Quarter Horse Association", write a program to output an abbreviation of the string, \(\mathrm{AQHA}\).
Modify the previous program to ask a user for a name of his or her organization and print an abbreviation of the name. Realize that the name of the organization consists of any number of words.
Repeat the previous exercise using dialog boxes for input and output. An input dialog box is used to input a name of the organization. Then, a message dialog box displays the abbreviation of the
Indicate whether the following statements are syntactically correct or incorrect. If incorrect, indicate what is wrong with the statement: A. int [] array[]; *B. double data [] = new data []; *C. int
Assume that a one-dimensional array named intArray of type int is declared, created, and initialized correctly. Write a code segment to compute the sum of all numbers stored in the even-numbered
Using the array intArray described in the previous exercise, write a code segment to output all the even numbers in the array, regardless of their position in the array.
What is the output from the following code segment? double [] [] grades; grades = new double [34] [15]; System.out.println (grades [11] .length); System.out.println (grades [34].length) ;
What is the output from the following code segment? int[] [] intArray = {{2, 5, 4), (6, 3), (9, 7, 1, 5}}; (intArray [0].length); (int Array [2]. length); System.out.println System.out.println
Using the array scores discussed in Sect. 7.8.2, write a code segment to output all the exam scores stored in the array. Each row should contain scores for all four students as shown below: exam 1
Using the array scores discussed in Sect. 7.8, write a method to find the average for a particular exam. The method should take a reference to a two-dimensional array and a column number as
Using the array scores discussed in Sect. 7.9, write a code segment to find the lowest score in the entire array and output it.
Using the array scores discussed in Sect. 7.9, write a code segment to find the highest score for each exam and output the score along with the student's name.
Write a code segment to perform a sequential search on a one-dimensional array. Assume that the set of data could contain duplicates. If the item being searched for is found in the array, record the
Develop a program to store names in a one-dimensional array. The program should initially create a one-dimensional array which holds ten String values. As the user enters names one by one, each name
Write a complete program to create an array of Card object discussed in Sect. 5.6.2. The program should ask a user for the number of cards and using a loop to initialize each card. Perform a couple
Write the following code segments concerning a three-dimensional array.A. Write a statement to declare a 3 by 2 by 5 three-dimensional array of type int.B. Write a statement to create the array
Draw series of contour diagrams to show the state of execution of the program in Fig. 8.1 for x=2x=2 and n=3n=3. import java.util.*; class Ch8Samplel { public static void main (String [] args) { }
Draw series of contour diagrams to show the state of execution of the program in Fig. 8.10 for \(n=2\). import java.util.; class Ch8Sample2 { public static void main(String[] args) { } Scanner
Given the complete program in Sect. 8.4, what would happen if the numbers 36 and 8 were input in reverse order? How many contours for gcd would need to be drawn?
Consider the program in Fig. 8.10 where Lines 22 and 23 are swapped. Draw a series of contour diagrams to show the state of execution for \(n=3\). import java.util.*; class Ch8Sample2 ( public static
Trace the program in Fig. 8.1 for \(x=2\) and \(n=5\) and draw the tree similar to the one in Fig. 8.21. import java.util.*; class Ch8Samplel { public static void main(String[] args) { Scanner
Trace the program in Fig. 8.10 for \(n=5\) and draw the tree similar to the one in Fig. 8.21 . import java.util..; class Ch8Sample2 { public static void main(String[] args) { Scanner scanner;)
Write a recursive method to reverse a given string. The method accepts a string as a parameter and returns the reverse of the string. For example, if the argument is Java, then the method returns
Write a recursive method to multiply two positive integers using repeated addition.
Write a recursive method to compute the factorial of a nonnegative integer using the definition shown below:\[\operatorname{factorial}(n)=\{\text { if } n \geq 1 \text {, then } n * \text {
Write a recursive method to compute the binomial coefficient using the definition shown below:\[\begin{aligned}\operatorname{binomial}(n, k)=\{ & \text { if } k=0 \text { or } n=k, \text { then } 1,
Find a reference on how to convert a decimal number to a binary number [10] and then write a recursive method to perform the conversion.
Write a recursive method to output a string a certain number of times. A user will input a string and how many time the string will be printed. An example output to print "Book" 5 times along with
Showing 1 - 100
of 741
1
2
3
4
5
6
7
8