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
building java programs a back to basics approach
Questions and Answers of
Building Java Programs A Back to Basics Approach
Write a method called numUnique that takes three integers as parameters and returns the number of unique integers among the three. For example, the call numUnique(18, 3, 4) should return 3 because
What output is produced by the following program? 1 public class CharMystery { public static void printRange (char startLetter, char endLetter) { for (char letter = startLetter; letter
Write a method called perfectNumbers that accepts an integer maximum as its parameter and prints all “perfect numbers” up to and including that maximum. A perfect number is an integer that is
Write an if statement that tests to see whether a String begins with a capital letter.
Write a method called printAcronym that accepts a string as its parameter and prints the first letter of each word of the string as an acronym. For example, the call of printAcronym("Breath of the
What is wrong with the following code, which attempts to count the number occurrences of the letter 'e' in a String , case-insensitively? int count = 0; for (int i = 0; i < s.length (); i++) { if
Consider a String stored in a variable called name that stores a person’s first and last name (e.g., “Marla Singer”). Write the expression that would produce the last name followed by the first
Write code to examine a String and determine how many of its letters come from the second half of the alphabet (that is, have values of 'n' or subsequent letters). Compare case-insensitively, such
Consider a method printTriangleType that accepts three integer arguments representing the lengths of the sides of a triangle and prints the type of triangle that these sides form. The three types are
Consider a method getGrade that accepts an integer representing a student’s grade percentage in a course and returns that student’s numerical course grade. The grade can be between 0.0 (failing)
The following method attempts to return the median (middle) of three integer values, but it contains logic errors. In what cases does the method return an incorrect result? How can the code be fixed?
Write a method called hasAnOddDigit that returns whether a given positive integer has at least one digit whose value is odd. Return true if the number has at least one odd digit and false if none of
Write a piece of code that prompts the user for a number and then prints a different message depending on whether the number was an integer or a real number. Here are two sample dialogues:Type a
Write a method called charsSorted that accepts a string as its parameter and returns true if the characters in the string appear in sorted alphabetical order. For example, the calls of
Write code that prompts for three integers, averages them, and prints the average. Make your code robust against invalid input.
Identify the various assertions in the following code as being always true, never true, or sometimes true and sometimes false at various points in program execution. The comments indicate the points
Identify the various assertions in the following code as being always true, never true, or sometimes true and sometimes false at various points in program execution. The comments indicate the points
Identify the various assertions in the following code as being always true, never true, or sometimes true and sometimes false at various points in program execution. The comments indicate the points
Write a program to spell out MISSISSIPPI using block letters like the following (one per line): M IIIII sssss PPPPPP MM MM S P M M M M I P P M M M Sssss PPPPPP M M S M M S P M M IIIII SSSss P
Which of the following is the correct syntax to output a message?a. System.println(Hello, world!);b. System.println.out('Hello, world!');c. System.println("Hello, world!");d.
Write a for loop that produces the following output:1 4 9 16 25 36 49 64 81 100For added challenge, try to modify your code so that it does not need to use the * multiplication operator.
What is the result of the following expression?1 + 2 * 3 + 7 * 2 % 5a. 1b. 2c. 5d. 11e. 21
Imagine you are writing a personal fitness program that stores the user’s age, gender, height (in feet or meters), and weight (to the nearest pound or kilogram). Declare variables with the
It’s common to print a rotating, increasing list of single-digit numbers at the start of a program’s output as a visual guide to number the columns of the output to follow. With this in mind,
What is the output of the following sequence of loops? for (int i = 1; i
What is the output of the following sequence of loops? for (int i = 1; i
Write a program that produces the following output using nested for loops. Use a class constant to make it possible to change the number of stairs in the figure. ******* /ハ* ****** ****** /ハ *
What are the values of a , b , and c after the following statements?int a = 5;int b = 10;int c = b;a = a + 1;b = b - 1;c = c + a;
Rewrite the code from the previous exercise to be shorter, by declaring the variables together and by using the special assignment operators (e.g., += , −= , *= , and /= ) as appropriate.Data from
What are the values of i , j , and k after the following statements?int i = 2;int j = 3;int k = 4;int x = i + j + k;i = x - i - j;j = x - j - k;k = x - i - k;
What is the output from the following code?int max;int min = 10;max = 17 − 4 / 10;max = max + 6;min = max − min;System.out.println(max * 2);System.out.println(max +
Use your pseudocode from the previous exercise to write a Java program called Window that produces the preceding figure as output. Use nested for loops to print the repeated parts of the figure. Once
The following program redundantly repeats the same expressions many times. Modify the program to remove all redundant expressions using variables of appropriate types. public class ComputePay {
Write a Java program called StarFigure that produces the following output. Use nested for loops to capture the structure of the figure. //// ★★素* **1* // /*** ******* ////************ **\\\\
The following program redundantly repeats the same expressions many times. Modify the program to remove all redundant expressions using variables of appropriate types. // This program computes the
Modify your DollarFigure program from the previous exercise to become a new program called DollarFigure2 that uses a global constant for the figure’s height. (You may want to make loop tables
Complete the code for the following for loop:so that it prints the following numbers, one per line:−41432506886 for (int i 1; i
Write a complete Java program called Stewie that prints the following output: I| victory is mine! ||
Why do computers use binary numbers?
Write a complete Java program called Spikey that prints the following output: W// /// 1/ハ ハ
Convert each of the following decimal numbers into its equivalent binary number:a. 6b. 44c. 72d. 131
Sometimes we write similar letters to different people. For example, you might write to your parents to tell them about your classes and your friends and to ask for money; you might write to a friend
Write a complete Java program called WellFormed that prints the following output:
What is the decimal equivalent of each of the following binary numbers?a. 100b. 1011c. 101010d. 1001110
Write a program that produces as output the lyrics to the repetitive song, “There Was an Old Lady Who Swallowed a Fly,” by Simms Taback. Use methods for each verse and the refrain. Your methods
Write a complete Java program called Difference that prints the following output:
In your own words, describe an algorithm for baking cookies. Assume that you have a large number of hungry friends, so you’ll want to produce several batches of cookies!
Write a program that produces as output the words of “The Twelve Days of Christmas.” (Static methods simplify this task.) Here are the first two verses and the last verse of the song: On the
Write a complete Java program called MuchBetter that prints the following output: A "quoted" String is 'much' better if you learn the rules of "escape sequences." Also, "" represents an empty String.
What is the difference between the file MyProgram.java and the file MyProgram.class?
Write a program that produces as output the words of “The House That Jack Built.” Use methods for each verse and for repeated text. Here are lyrics to use: This is the house that Jack built. This
Write a complete Java program called Meta whose output is the text that would be the source code of a Java program that prints “Hello, world!” as its output.
Which of the following can be used in a Java program as identifiers? println first-name AnnualSalary "hello" АВС 42isTheAnswer for sum of data average В4
Write a program that produces as output the words of the song, “Bought Me a Cat.” Use methods for each verse and for repeated text.
Write a complete Java program called Mantra that prints the following output. Use at least one static method besides main. There's one thing every coder must understand: The System.out.println
Write a program that produces as output the words of the following silly song. Use methods for each verse and for repeated text. Here are the song’s complete lyrics:
Write a complete Java program called Stewie2 that prints the following output. Use at least one static method besides main. /// //// ///// || Victory is mine! I| || Victory is mine! || II Victory is
What is the output produced from the following statements?System.out.println("\"Quotes\"");System.out.println("Slashes \\//");System.out.println("How '\"confounding' \"\\\" it is!");
Write a program called Egg that displays the following output:
What is the output produced from the following
What is the output produced from the following statements?System.out.println("Shaq is 7'1");System.out.println("The string \"\" is an empty message.");System.out.println("\\'\"\"");
Modify the program from the previous exercise to become a new program Egg2 that displays the following output. Use static methods as appropriate.
What is the output produced from the following
Write a Java program called TwoRockets that generates the following output. Use static methods to show structure and eliminate redundancy in your solution. Note that there are two rocket ships next
What is the output produced from the following statements?System.out.println("Dear \"DoubleSlash\" magazine,");System.out.println();System.out.println("\tYour publication confuses me. Is
Write a program called FightSong that produces this output. Use at least two static methods to show structure and eliminate redundancy in your solution. Go, team, go! You can do it. Go, team, go! You
Write a Java program called StarFigures that generates the following output. Use static methods to show structure and eliminate redundancy in your solution. ***** ***** 大 大★★★* ***** *****
What series of println statements would produce the following output?"Several slashes are sometimes seen,"said Sally. "I've said so." See?\ / \\ // \\\ ///
What series of println statements would produce the following output?This is a test of yourknowledge of "quotes" usedin 'string literals.'You're bound to "get it right"if you read the section
Write a Java program called Lanterns that generates the following output. Use static methods to show structure and eliminate redundancy in your solution. ★大 ** ***** **** オ ***** *********
Write a println statement that produces the following output:/ \ // \\ /// \\\
Write a Java program called EggStop that generates the following output. Use static methods to show structure and eliminate redundancy in your solution. STOP
Rewrite the following code as a series of equivalent System.out.println statements (i.e., without any System.out.print statements):System.out.print("Twas ");System.out.print("brillig and
Write a program called Shining that prints the following line of output 1000 times:All work and no play makes Jack a dull boy.You should not write a program that uses 1000 lines of source code; use
What is the output of the following program? Note that the program contains several comments. public class Commentary { 2 public static void main (String [] args) { System.out.println ("some lines of
Write a program called FarewellGoodBye that prints the following lyrics. Use static methods to show structure and eliminate redundancy in your solution. Farewell, goodbye, au revoir, good night! It's
Name the three errors in the following program: public MyProgram { public static void main (String [] args) { System.out.println("This is a test of the") System.out.Println ("emergency broadcast
Name the four errors in the following program:
Name the four errors in the following program: public class Famous Speech public static void main (String []) { System.out.println ("Four score and seven years ago, "); System.out.println ("our
Which of the following method headers uses the correct syntax?a. Public static example() {b. Public static void example() {c. Public void static example() {d. Public static example void[] {e. Public
What is the output of the following program? (You may wish to draw a structure diagram first.) public class Tricky { public static void main (String [] args) { messagel (); message2 ();
What is the output of the following program? (You may wish to draw a structure diagram first.) public class Strange { public static void first () { System.out.println ("Inside first method"); public
What would have been the output of the preceding program if the third method had contained the following statements? public static void third () { first (); second (); System.out.println ("Inside
What would have been the output of the Strange program if the main method had contained the following statements? (Use the original version of third, not the modified version from the most recent
What is the output of the following program? (You may wish to draw a structure diagram first.) public class Confusing { public static void method2 () { method1 (); System.out.println ("I am method
What would have been the output of the preceding program if the method3 method had contained the following statements? public static void method3 () { method1 (); method2 () ; System.out.println ("I
What would have been the output of the Confusing program if the main method had contained the following statements? (Use the original version of method3 , not the modified version from the most
The following program contains at least 10 syntax errors. What are they?
Consider the following program, saved into a file named Example.java:What would happen if each of the following changes were made to the Example program? For example, would there be no effect, a
The following program is legal under Java’s syntax rules, but it is difficult to read because of its layout and lack of comments. Reformat it using the rules given in this chapter, and add a
The following program is legal under Java’s syntax rules, but it is difficult to read because of its layout and lack of comments. Reformat it using the rules given in this chapter, and add a
In physics, a common useful equation for finding the position of a body in linear motion at a given time , based on its initial position, initial velocity , and rate of acceleration , is the
Which of the following are legal int literals?22 1.5 −1 2.3 10.0 5. −6875309 '7'
The Fibonacci numbers are a sequence of integers in which the first two elements are 1, and each following element is the sum of the two preceding elements. The mathematical definition of each kth
Trace the evaluation of the following expressions, and give their resulting values:a. 2 + 3 * 4 − 6b. 14 / 7 * 2 + 30 / 5 + 1c. (12 + 3) / 4 * 2d. (238 % 10 + 3) % 7e. (18 − 7) * (43 % 10)f. 2 +
Trace the evaluation of the following expressions, and give their resulting values:a. 4.0 / 2 * 9 / 2b. 2.5 * 2 + 8 / 5.0 + 10 / 3c. 12 / 7 * 4.4 * 2 / 4d. 4 * 3 / 8 + 2.5 * 2e. (5 * 7.0 / 2 − 2.5)
Write nested for loops to produce the following output:********************
Write a program that produces the following hourglass figure as its output using nested for loops: \::/ 1::\ 1:: 7::::: 1::::::
Write nested for loops to produce the following output:***************
Trace the evaluation of the following expressions, and give their resulting values:a. 2 + 2 + 3 + 4b. "2 + 2" + 3 + 4c. 2 + " 2 + 3 " + 4d. 3 + 4 + " 2 + 2"e. "2 + 2 " + (3 + 4)f. "(2 + 2) " + (3 +
Showing 900 - 1000
of 1041
1
2
3
4
5
6
7
8
9
10
11