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
java an introduction to problem solving and progra
Questions and Answers of
Java An Introduction to Problem Solving and Progra
Create a JavaFx application that draws a pattern of evenly spaced circles. Use four constants to control the pattern: the number of circles to draw, the radius of the first circle, the change in the
Suppose that you work for a beverage company. The company wants to know the optimal cost for a cylindrical container that holds a specified volume. Write a fragment of code that uses an
Write a JavaFx application that draws a bull’s-eye pattern. The center should be a filled-in blue circle with a diameter of 100 pixels. The center circle should be surrounded by five rings that
Write a fragment of code that computes the final score of a baseball game. Use a loop to read the number of runs scored by both teams during each of nine innings. Display the final score afterwards.
Repeat Programming Project 7, but write the program as JavaFx application. Use a constant for the initial velocity of the ball. Draw a circle for the position of the ball at each second. The
Define an enumeration for each of the months in the year. Use a for-each statement to display each month.
Your country is at war and your enemies are using a secret code to communicate with one another. You have managed to intercept a message that reads as follows::mmZ\dxZmx]ZpgyThe message is obviously
Suppose we attend a party. To be sociable, we will shake hands with everyone else. Write a fragment of code using a for statement that will compute the total number of handshakes that occur. Upon
Holy digits Batman! The Riddler is planning his next caper somewhere on Pennsylvania Avenue. In his usual sporting fashion, he has left the address in the form of a puzzle. The address on
Develop an algorithm for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the program returns two values: the number of digits in the guess that are in
Write a program that reads a string for a date in the format month / day / year and displays it in the format day . month . year, which is a typical format used in Europe. For example, if the input
Write a program that inputs two strings that represents a time of day using the format HH:MM:SS AM or PM and then outputs the time elapsed from the first to the second time in minutes and seconds.For
Repeat the previous exercise, but change next to nextLine in the statement that assigns a value to b.Previous exerciseWhat does the Java codeScanner keyboard = new
If u = 2, v = 3, w = 5, × = 7, and y = 11, what is the value of each of the following expressions, assuming int variables?u + v * w + ×u + y % v * w + ×u++ / v + u++ * w
Write a program that will compute statistics for eight coin tosses. The user will enter either an h for heads or a t for tails for the eight tosses. The program will then display the total number and
Suppose we can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. We can redeem six coupons for one chocolate bar from the machine. This means that once
Write a loop that will create a new string that is the reverse of a given string.
You have three identical prizes to give away and a pool of ten finalists. The finalists are assigned numbers from 1 to 10. Write a program to randomly select the numbers of three finalists to receive
Write a loop that will count the number of blank characters in a given string.
Write a program that simulates a bouncing ball by computing its height in feet at each second as time passes on a simulated clock. At time zero, the ball begins at height zero and has an initial
Write a program that asks the user to enter the size of a triangle (an integer from 1 to 50). Display the triangle by writing lines of asterisks. The first line will have one asterisk, the next two,
Write a for statement to compute the sum 1 + 2 + 3 + 4 + 5 + … + n .
Repeat Practice Program 7 using JOptionPane, which is described in the graphics supplements of Chapters 2 and 3.Practice Program 7Combine the programs from Programming Projects 5 and 6 to read
Convert the following code so that it uses nested while statements instead of for statements:int s = 0;int t = 1;for (int i = 0; i < 10; i++){s = s + i;for (int j = i; j > 0; j−−){t = t *
Modify Programming Project 5 from Chapter 2 to check the validity of input data. Valid input is no less than 25 cents, no more than 100 cents, and an integer multiple of 5 cents. Compute the change
Write a fragment of code that will compute the sum of the first n positive odd integers. For example, if n is 5, you should compute 1 + 3 + 5 + 7 + 9.
Write a program that reads a bank account balance and an interest rate and displays the value of the account in ten years. The output should show the value of the account for three different methods
For all of the following words, if you move the first letter to the end of the word, and then spell the result backwards, you will get the original word: banana dresser grammar potato revive uneven
Develop an algorithm for computing the month-by-month balance in your savings account. You can make one transaction—a deposit or a withdrawal each month. Interest is added to the account at the
Write a program that implements your algorithm from Exercise 3.Exercise 3.Develop an algorithm for a simple game of guessing at a secret five-digit code. When the user enters a guess at the code, the
Write a fragment of code that will read words from the keyboard until the word done is entered. For each word except done, report whether its first character is equal to its last character. For
Write Java statements that create a yes-or-no dialog box to answer the question, “Are you in college?”
Given that the int variable temp contains a temperature that is not negative, write a Java statement that uses the conditional operator to set the String variablelabel to either "degree" or
Repeat Exercise 13, but use a multibranch if-else statement instead of a switch statement.Exercise 13Imagine a program that displays a menu of five possible choices, lettered a through e. Suppose the
Repeat the previous exercise, but define an enumeration and use it within the switch statement.Previous exerciseImagine a program that displays a menu of five possible choices, lettered a through e.
Imagine a program that displays a menu of five possible choices, lettered a through e. Suppose the user’s selection is read into the character variable choice. Write a switch statement that reacts
Consider the previous question, but include + or − letter grades. A+ is 4.25, A− is 3.75, B+ is 3.25, B− is 2.75, and so on.a. Why can’t we use one switch statement with no other conditionals
Write a switch statement to convert a letter grade into an equivalent numeric value on a fourpoint scale. Set the value of the variable gradeValue to 4.0 for an A, 3.0 for a B, 2.0 for a C, 1.0 for a
The following flowchart contains a series of questions to determine what kind of haircut to get. Write a program that asks the questions to the user and outputs the recommended haircut based on the
Consider the boolean expression((2 < 5) && (x < 100)). Why is this expression probably not what the programmer intended?
Repeat Programming Project 8 in Chapter 1, but add yes-or-no dialogs to allow the user to make the following color changes:Change the color of the solid center circle from black to red.Change the
Consider the boolean expression((x > 10) || (x < 100)). Why is this expression probably not what the programmer intended?
Write a JavaFx application to draw the five interlocking rings that are the symbol of the Olympics. The color of the rings, from left to right, is blue, yellow, black, green, and red.
The following code fragment will not compile. Why?if !x > x + yx = 2 * x;elsex = x + 3;
Write a program to play the rock-paper-scissor game. Each of two users types in either P, R, or S. The program then announces the winner as well as the basis for determining the winner: paper covers
What is the value of each of the following boolean expressions if x is 5,y is 10, and z is 15?a. (x < 5 && y > x)b. (x < 5 || y > x)c. (x > 3 || y < 10 && z == 15)d.
Repeat Programming Project 11 in Chapter 2, but if the displacement is positive then output that “The (material name) will expand by” the displacement in meters. If the displacement is negative
We would like to assess a service charge for cashing a check. The service charge depends on the amount of the check. If the check amount is less than $10, we will charge $1. If the amount is greater
Repeat Programming Project 5 but in addition ask the user if he or she is a. Sedentaryb. Somewhat active (exercise occasionally)c. Active (exercise 3–4 days per week)d. Highly active (exercise
Consider the following fragment of code:if (x > 5){System.out.println("A");if (x < 10)System.out.println("B");}elseSystem.out.println("C");What is displayed if x isa. 4;b. 5;c. 6;d. 9;e. 10;f.
Repeat the calorie-counting program described in Programming Project 8 from Chapter 2. This time ask the user to input the string “M” if the user is a man and “W” if the user is a woman. Use
Write a program that reads a string from the keyboard and tests whether it contains a valid date. Display the date and a message that indicates whether it is valid. If it is not valid, also display a
Consider the following fragment of code:if (x > 5)System.out.println("A");else if (x < 10)System.out.println("B");elseSystem.out.println("C");What is displayed if x isa. 4;b. 5;c. 6;d. 9;e.
Suppose that we are working for an online service that provides a bulletin board for its users. We would like to give our users the option of filtering out profanity. Suppose that we consider the
Suppose you are writing a program that asks the user to give a yes-or-no response. Assume that the program reads the user’s response into the Stringvariableresponse.a. If response is yes or y, set
Repeat any of the previous Practice Programs using JOptionPane, which is described in the graphics supplement at the end of Chapter 2.
Write a fragment of code that will change the integer value stored in x as follows. If x is even, divide x by 2. If x is odd, multiply x by 3 and subtract 1.
Write a fragment of code that will test whether an integer variable score contains a valid test score. Valid test scores are in the range 0 to 100.
Define named constants that you could use in Programming Project 6 in Chapter 1.Programming Project 6Write an JavaFx application that displays the following pattern:
Repeat Exercise 18 in Chapter 1, but define and use named constants.Exercise 18Write statements that can be used in a JavaFX application to draw the five interlocking rings that are the symbol of the
Many sports have constants embedded in their rules. For example, baseball has 9 innings, 3 outs per inning, 3 strikes in an out, and 4 balls per walk. We might encode the constants for a program
How does a computer’s main memory differ from its auxiliary memory?
Write a Java program that displays the following picture. Write a sequence of println statements that display lines of asterisks and blanks. **** ** * **** ****** * ** ************** **** ** **
After you use a text editor to write a program, will it be in main memory or auxiliary memory?
Write a complete program for the problem described in Exercise 9.Exercise 9. Given a person’s year of birth, the Birthday Wizard can compute the year in which the person’s nth birthday will
When a computer executes a program, will it be in main memory or auxiliary memory?
Write a complete program for the problem described in Exercise 10.Exercise 10.Write statements that can be used in a Java program to read two integers and display the number of integers that lie
How does machine language differ from Java?
Write an JavaFx application similar to the one in Listing 1.2 that displays a picture of a snowman. Draw three circles, one above the other. Make the circles progressively smaller from bottom to top.
How does bytecode differ from machine language?
Write an JavaFx application for the problem described in Exercise 18.Exercise 18.Write statements that can be used in a JavaFX application to draw the five interlocking rings that are the symbol of
What would the following statements, when used in a Java program, display on the screen?int age;age = 20;System.out.println ("My age is");System.out.println(age);
Write an JavaFx application that displays the following pattern:
Write a statement or statements that can be used in a Java program to display the following on the screen:321
Write statements that can be used in a Java program to read your age, as entered at the keyboard, and display it on the screen.
Given a person’s year of birth, the Birthday Wizard can compute the year in which the person’s nth birthday will occur or has occurred. Write statements that can be used in a Java program to
Write statements that can be used in a Java program to read two integers and display the number of integers that lie between them, including the integers themselves. For example, four integers are
A single bit can represent two values: 0 and 1. Two bits can represent four values: 00, 01, 10, and 11. Three bits can represent eight values: 000, 001, 010, 011, 100, 101, 110, and 111. How many
Find the documentation for the Java Class Library on the Oracle® Web site. (At this writing, the link to this documentation is https://docs.oracle.com/javase/8/docs/api/.) Then find the description
Self-Test Question 27 asked you to think of some attributes for a song object. What attributes would you want for an object that represents a play list containing many songs?Self-Test Question 27What
What behaviors might a song have? What behaviors might a play list have? Contrast the difference in behavior between the two kinds of objects.
What attributes and behaviors would an object representing a credit card account have?
Suppose that you have a number x that is greater than 1. Write an algorithm that computes the largest integer k such that 2 is less than or equal to x.
Write statements that can be used in a JavaFX application to draw the five interlocking rings that are the symbol of the Olympics. (Don’t worry about the color.)
Find the documentation for the class Graphics Context in the JavaFX Class Library. (See Exercise 12.) Learn how to use the method strokeRect. Then write statements that can be used in a JavaFx
Write statements that can be used in a JavaFx application to draw the outline of a crescent moon.
Write a program that demonstrates the approximate nature of floating point values by performing the following tasks:Use Scanner to read a floating-point value x.Compute 1.0 / x and store the result
Write a program that converts degrees from Fahrenheit to Celsius, using the formulaDegreesC = 5(DegreesF −32)/9Prompt the user to enter a temperature in degrees Fahrenheit as a whole number without
Write a program that demonstrates type casting of double values by performing the following tasks:Use Scanner to read a floating-point value x.Type cast x to an int value and store the result in
Write a program that reads a line of text and then displays the line, but with the first occurrence of hate changed to love. For example, a possible sample dialogue might be Enter a line of
Write a program that demonstrates the operator % by performing the following tasks:Use Scanner to read a floating-point value x.Compute x % 2.0 and store the result in y.Display x and y clearly
Write a program that will read a line of text as input and then display the line with the first word moved to the end of the line. For example, a possible sample interaction with the user might
Write a program that asks the user to enter a favorite color, a favorite food, a favorite animal, and the first name of a friend or relative. The program should then print the following two lines,
What changes to the ChangeMaker program in Listing 2.3 are necessary if it also accepts coins for one dollar and half a dollar?Listing 2.3 import java.util.Scanner; public class ChangeMaker { public
Write a program that determines the change to be dispensed from a vending machine. An item in the machine can cost between 25 cents and a dollar, in 5 cent increments (25, 30, 35, … , 90, 95, or
If the int variable × contains 10, what will the following Java statements display?System.out.println("Test 1" + × * 3 * 2.0);System.out.println("Test 2" + × * 3 + 2.0);Given these results,
Write a program that reads a 4-bit binary number from the keyboard as a string and then converts it into decimal. For example, if the input is 1100, the output should be 12. Break the string into
Write some Java statements that use the String methods indexOf and substring to find the first word in a string. We define word to be a string of characters that does not include whitespace. For
Many private water wells produce only 1 or 2 gallons of water per minute. One way to avoid running out of water with these low-yield wells is to use a holding tank. A family of 4 will use about 250
Repeat the previous exercise, but find the second word in the string.Previous exerciseWrite some Java statements that use the String methods indexOf and substring to find the first word in a string.
Showing 300 - 400
of 407
1
2
3
4
5