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
Ask a Question
Search
Search
Sign In
Register
study help
computer science
introduction to java programming and data structure
Questions and Answers of
Introduction to Java Programming and Data Structure
Write a program that displays three cards randomly selected from a deck of 52, as shown in Figure 14.43c. The card image files are named 1.png, 2.png, . . . , 52.png and stored in the image/card
Write a program that displays five texts vertically, as shown in Figure 14.44a. Set a random color and opacity for each text and set the font of each text to Times Roman, bold, italic, and 22 pixels.
Write a program that displays a string “Welcome to Java” around the circle, as shown in Figure 14.44b. A00 Exercise14 05 JAVA COME (b) WEL
Write a program that displays a 10-by-10 square matrix, as shown in Figure 14.45a. Each element in the matrix is 0 or 1, randomly generated. Display each number centered in a text field. Use
Write a program that prompts the user to enter two strings, and reports whether the second string is a substring of the first string.Enter string s1: ABCDEnter string s2: BCBC is a substring of
A school has 100 lockers and 100 students. All lockers are closed on the first day of school. As the students enter, the first student, denoted as S1, opens every locker. Then the second student, S2,
Write a program that passes a string to the command line and displays the number of uppercase letters in the string.
Write a program that passes an unspecified number of integers from command line and displays their total.
In Listing 7.8, you used selection sort to sort an array. The selection-sort method repeatedly finds the smallest number in the current array and swaps it with the first. Rewrite this program by
Write the following method that returns true if the list is already sorted in nondecreasing order:public static boolean isSorted(int[] list)Write a test program that prompts the user to enter a list
Write a program that prompts the user to enter the number of students, the students’ names, and their scores and prints student names in decreasing order of their scores. Assume the name is a
Write the following method that returns a random number between start and end, excluding the numbers.public static int getRandom(int start, int end, int... numbers)For example, invoking
Revise Programming Exercise 6.30 to run it 10,000 times and display the number of winning games.
Listing 2.7, ShowCurrentTime.java, displays the current time. Revise this example to display the current date and time. The calendar example in Listing 6.12, PrintCalendar.java, should give you some
Implement the following two methods:/** Return true if the sum of every two sides is* greater than the third side. */public static boolean isValid(double side1, double side2, double side3)/** Return
Write a method that computes the commission, using the scheme in Programming Exercise 5.39. The header of the method is as follows:public static double computeCommission(double salesAmount)Write a
Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the name of the student with the highest score. Use the next() method
Write a class that contains the following two methods:/** Convert from feet to meters */public static double footToMeter(double foot)/** Convert from meters to feet */public static double
Write a method to display a pattern as follows:The method header ispublic static void displayPattern(int n)Write a test program that prompts the user to enter a number n and invokes displayPattern(
Write the methods with the following headers:// Return the reversal of an integer, e.g., reverse(456) returns 654public static int reverse(int number)// Return true if number is a palindromepublic
Write a program that prompts the user to enter a string and displays the number of the uppercase letters in the string.Enter a string: Welcome to JavaThe number of uppercase letters is 2
Assume that the letters A, E, I, O, and U are vowels. Write a program that prompts the user to enter a string, and displays the number of vowels and consonants in the string.Enter a string:
that prompts the user to enter a string and displays the characters at odd positions. Here is a sample run:Enter a string: Beijing ChicagoBiigCiao
Write a program that prompts the user to enter a string and displays the string in reverse order.Enter a string: ABCDThe reversed string is DCBA
A short value is stored in 16 bits. Write a program that prompts the user to enter a short integer and displays the 16 bits for the integer. Here are sample runs:Enter an integer: 5The bits are
Rewrite Programming Exercise 5.39 as follows:■■ Use a for loop instead of a do-while loop.■■ Let the user enter COMMISSION_SOUGHT instead of fixing it as a constant.
Write a program that prompts the user to enter a decimal integer then displays its corresponding binary value. Don’t use Java’s Integer. toBinaryString(int) in this program.
Write a program that prompts the user to enter the year and first day of the year and displays the calendar table for the year on the console. For example, if the user entered the year 2013, and 2
You can approximate e using the following summation:Write a program that displays the e value for i = 1, 2, …, and 20. Format the number to display 16 digits after the decimal point. (Hint: Because
Write a program to compute the following summation: 1 3 5 7 9. 11 95 97 3 7 9. 11 13 97 99 +
Another solution for Listing 5.9 to find the greatest common divisor of two integers n1 and n2 is as follows: First find d to be the minimum of n1 and n2, then check whether d, d–1, d–2, …, 2,
Write a program that displays all the numbers from 100 to 200 (10 per line) that are divisible by 5 or 6, but not both. Numbers are separated by exactly one space.
Write a program that displays all the numbers from 100 to 1,000 (10 per line) that are divisible by 5 and 6. Numbers are separated by exactly one space.
Write a program that prompts the user to enter the number of students and each student’s name and score, and finally displays the student with the highest score and the student with the
Write a program that prompts the user to enter a string and displays its length and its first character.
The international standard letter/number mapping found on the telephone is shown below:Write a program that prompts the user to enter a lowercase or uppercase letter and displays its corresponding
Write a program that prompts the user to enter a hex digit and displays its corresponding binary number in four digits. For example, hex digit 7 is 0111 in binary. Hex digits can be entered either in
Write a program that prompts the user to enter an integer between 0 and 15 and displays its corresponding hex number. For an incorrect input number, display invalid input. Here are some sample
Suppose a pentagon is centered at (0, 0) with one point at the 0 o’clock position, as shown in Figure 4.4c. Write a program that prompts the user to enter the radius of the bounding circle of a
Write a program that generates three random points on a circle centered at (0, 0) with radius 40 and displays three angles in a triangle formed by these three points, as shown in Figure 4.4a. Display
A shipping company uses the following function to calculate the cost (in dollars) of shipping based on the weight of the package (in pounds).Write a program that prompts the user to enter the weight
Revise Listing 3.8, Lottery.java, to generate a lottery of a threedigit integer. The program prompts the user to enter a three-digit integer and determines whether the user wins according to the
Write a program that prompts the user to enter an integer for today’s day of the week (Sunday is 0, Monday is 1, . . . , and Saturday is 6). Also prompt the user to enter the number of days after
How cold is it outside? The temperature alone is not enough to provide the answer. Other factors including wind speed, relative humidity, and sunshine play important roles in determining coldness
Write a program that prompts the user to enter the side of a hexagon and displays its area. The formula for computing the area of a hexagon iswhere s is the length of a side. Here is a sample
Write a program that reads in the radius and length of a cylinder and computes the area and volume using the following formulas:area = radius * radius * πvolume = area * lengthHere is a sample
Write a program that reads a Celsius degree in a double value from the console, then converts it to Fahrenheit, and displays the result. The formula for the conversion is as follows:fahrenheit = (9 /
Showing 300 - 400
of 347
1
2
3
4