Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2, Problem 18PE
Writing large letters. A large letter H can be produced like this:
It can be declared as a string literal like this:
final string LETTER_H = "* *%n* *%n*****%n* *%n* *%n";
Print the string with System.out.printf. The %n format specifiers cause line breaks in the output. Do the same for the letters E, L, and O. Then write in large letters:
H
E
L
L
O
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program in Eclipse that prompts the user to enter a string and displays the number of vowels and consonants in the string. Assume letters A, E, I, O, U (or a, e, i, o, u) as the vowels.
Given a string on one line and an integer number on a second line, add a copy of the last number of characters of the string to the string's end. Then, output the result.
Ex: If the input is:
Fuzzy bear
4
the output is:
Fuzzy bearbear
Note: Using a pre-defined string function, the solution can be just one line of code.
#include <iostream>#include <string>using namespace std;
int main() { string strVar; int substrLen;
getline(cin, strVar); cin >> substrLen;
/* Your code goes here */
cout << strVar << endl; return 0;}
write a program that prompts the user toenter a string and displays the number of vowels and consonants in the string. Assume lettersA, E, I, O, U (or a, e, i, o, u) as the vowels.1. Prompt the user for a String. (Note: The user input String may contain spaces)2. Print the number of vowels and consonants in the String. The count displayed mustaccount for all the vowels and consonants in the String regardless of case (upper orlower case). You must use a loop in your solution.Hint: charAt(index) and length() method for the String, toUpperCase(ch) (ortoLowerCase(ch)), isLetter(ch) method for the Character is helpful for thisassignment3. The output from the program must be enclosed in quotes as shown below in the samplerun of the program.
Chapter 2 Solutions
Big Java Late Objects
Ch. 2.1 - Declare a variable suitable for holding the number...Ch. 2.1 - What is wrong with the following variable...Ch. 2.1 - Declare and initialize two variables, unitPrice...Ch. 2.1 - Prob. 4SCCh. 2.1 - Some drinks are sold in four-packs instead of...Ch. 2.1 - Prob. 6SCCh. 2.1 - Prob. 7SCCh. 2.1 - Prob. 8SCCh. 2.1 - How would you explain assignment using the parking...Ch. 2.2 - A bank account earns interest once per year. In...
Ch. 2.2 - In Java, how do you compute the side length of a...Ch. 2.2 - The volume of a sphere is given by V=43r3 If the...Ch. 2.2 - Prob. 13SCCh. 2.2 - Prob. 14SCCh. 2.3 - Write statements to prompt for and read the users...Ch. 2.3 - What is wrong with the following statement...Ch. 2.3 - Prob. 17SCCh. 2.3 - What is problematic about the following statement...Ch. 2.3 - What is the output of the following statement...Ch. 2.3 - Using the printf method, print the values of the...Ch. 2.4 - Prob. 21SCCh. 2.4 - Suppose the architect specifies a pattern with...Ch. 2.4 - A robot needs to tile a floor with alternating...Ch. 2.4 - For a particular car, repair and maintenance costs...Ch. 2.4 - The shape of a bottle is approximated by two...Ch. 2.5 - What is the length of the string "Java Program"?Ch. 2.5 - Consider this string variable. String str = "Java...Ch. 2.5 - Use string concatenation to turn the string...Ch. 2.5 - Prob. 29SCCh. 2.5 - Prob. 30SCCh. 2 - Write declarations for storing the following...Ch. 2 - What is the value of mystery after this sequence...Ch. 2 - What is wrong with the following sequence of...Ch. 2 - Write the following mathematical expressions in...Ch. 2 - Write the following Java expressions in...Ch. 2 - What are the values of the following expressions?...Ch. 2 - What are the values of the following expressions,...Ch. 2 - What are the values of the following expressions?...Ch. 2 - Assuming that a and b are variables of type int,...Ch. 2 - Suppose direction is an integer angle between 0...Ch. 2 - Find at least five compile-time errors in the...Ch. 2 - Find three run-time errors in the following...Ch. 2 - Consider the following code segment. double...Ch. 2 - Explain the differences between 2, 2.0, 2, 2, and...Ch. 2 - Explain what each of the following program...Ch. 2 - Write pseudocode for a program that reads a word...Ch. 2 - Write pseudocode for a program that reads a name...Ch. 2 - Write pseudocode for a program that computes the...Ch. 2 - Modify the pseudocode for the program in How To...Ch. 2 - Prob. 20RECh. 2 - You are cutting off a piece of pie like this,...Ch. 2 - The following pseudocode describes how to obtain...Ch. 2 - Suppose you are given a string str and two...Ch. 2 - Prob. 24RECh. 2 - For each of the following computations in Java,...Ch. 2 - Prob. 26RECh. 2 - This chapter contains a number of recommendations...Ch. 2 - Write a program that displays the dimensions of a...Ch. 2 - Write a program that computes and displays the...Ch. 2 - Write a program that reads a number and displays...Ch. 2 - Write a program that prompts the user for two...Ch. 2 - Enhance the output of Exercise E2.4 so that the...Ch. 2 - Write a program that prompts the user for a...Ch. 2 - Write a program that prompts the user for a radius...Ch. 2 - Write a program that asks the user for the lengths...Ch. 2 - Improve the program discussed in How To 2.1 to...Ch. 2 - Write a program that helps a person decide whether...Ch. 2 - Write a program that asks the user to input The...Ch. 2 - File names and extensions. Write a program that...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Write a program that reads a number between 1,000...Ch. 2 - Printing a grid. Write a program that prints the...Ch. 2 - Write a program that reads in an integer and...Ch. 2 - Write a program that reads two times in military...Ch. 2 - Writing large letters. A large letter H can be...Ch. 2 - Write a program that transforms numbers 1, 2, 3, ,...Ch. 2 - Write a program that prints a Christmas tree:...Ch. 2 - Easter Sunday is the first Sunday after the first...Ch. 2 - In this project, you will perform calculations...Ch. 2 - The following pseudocode describes how a bookstore...Ch. 2 - The following pseudocode describes how to turn a...Ch. 2 - The following pseudocode describes how to extract...Ch. 2 - Giving change. Implement a program that directs a...Ch. 2 - An online bank wants you to create a program that...Ch. 2 - A video club wants to reward its best members with...Ch. 2 - Consider the following circuit. Write a program...Ch. 2 - The dew point temperature Td can be calculated...Ch. 2 - The pipe clip temperature sensors shown here are...Ch. 2 - Prob. 12PPCh. 2 - Consider the following tuning circuit connected to...Ch. 2 - According to the Coulomb force law, the electric...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What does the following program segment do? 1 for (i = 1; i = 5; i++) { 2 for (j = 1; j = 3; j++) { 3 for (k = ...
Java How To Program (Early Objects)
Refer to your answer to Checkpoint 14.31. In what package are the two classes?
Starting Out with Java: Early Objects (6th Edition)
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
The words that make up a high-level programming language are called______. a. binary instructions b. mnemonics ...
Starting out with Visual C# (4th Edition)
What is the output produced by the following lines of program code? double result = (1 / 2) 2; System.out.prin...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Java with out string formarrow_forwardcapCount.py make a program called capCount.py that has a function that takes in a string and prints the number of capital letters in the first line, then prints the sum of their indices in the second line. The string "hEllo, World" would should look like this: 28arrow_forwardGiven a first string on one line and a second string on a second line, append the second string to the first string and then output the result. Ex: If the input is: Fuzzy bear !!! the output is: Fuzzy bear!!! Note: Using a pre-defined string function, the solution can be just one line of code. 1 #include 2 #include 3 using namespace std; 4 5 int main() { string strInput; string endStr; 6. 7. 8. getline(cin, strInput); getline(cin, endStr); 10 11 12 cout << strInput << endl; return 0; 13 14 15 }arrow_forward
- Asaparrow_forwardWrite a program that asks the user to enter a series of single-digit numbers with nothing separating them. Read the input as a C-string or a string object. The program should display the sum of all the single-digit numbers in the string. For example, if the user enters 2514, the program should display 12, which is the sum of 2, 5, 1, and 4. The program should also display the highest and lowest digits in the string.arrow_forwardPART 2:Write a program that accepts as input a sentence in which all the words are run together, but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string “StopAndSmellTheRoses.” would be converted to “Stop and smell the roses.” If the word is “I”, leave it as an uppercase I. Also check if the sentence ends with a “.”(period). If it does not, add a period at the end of the sentence.You should use a method to perform the editing to the sentence.Print the original sentence and the converted version. You may do this in the method or in the main program, having returned the new string.Repeat this for as many lines as there are in the input file. Use at least 8 lines of data. Have some with only one word. Have some words with only one letter(a), and at least one time the word I in the middle of the sentence. Some should end with a “.” and some…arrow_forward
- Forms often allow a user to enter an integer. Write a program that takes in a string representing an integer as input, and outputs yes if every character is a digit 0-9. Ex: If the input is: 1995 the output is: yes Ex: If the input is: 42,000 or 1995! the output is: no Hint: Use a loop and the Character.isDigit() function. import java.util.Scanner; public class LabProgram {public static void main(String[] args) {Scanner scnr = new Scanner(System.in);String userString;// Add more variables as needed userString = scnr.next();arrow_forwardA palindrome is a word or phrase that reads the same forward and backward, ignoring blanks and considering uppercase and lowercase versions of the same letter to be equal. For example, the following are palindromes:warts n strawradarAble was I ere I saw Elbaxyzczyx Write a program that will accept a sequence of characters terminated by a period and will decide whether the string—without the period—is a palindrome. You may assume that the input contains only letters and blanks and is at most 80 characters long. Include a loop that allows the user to check additional strings until she or he requests that the program end. Hint: Define a static method called is Palindrome that begins as follows: /** Precondition: The array a contains letters and blanks in positions a[0] through a[used − 1]. Returns true if the string is a palindrome and false otherwise. */ public static boolean is a palindrome(char[] a int used) Your program should read the input characters into an array whose base…arrow_forwardJava program:; User's name. Write a program that prompts for and reads the user's first and last name (separately). Then print a string composed of the first letter of the user's first name, followed by the first five characters of the user's last name, followed by a random number in the range 10 to 99. Assume that the name is at least five letters long. Similar algorithms are sometimes used to generate user names for new computer accounts. wwwarrow_forward
- Read string integer value pairs from input until "Done" is read. For each string read: • If the following integer read is less than 40, output the string followed by ": low on stock". • Otherwise, output the string followed by ": well stocked". End each output with a newline. Ex: If the input is Oven 43 Curtain 7 Pillow 1 Done, then the output is: Oven: well stocked Curtain: low on stock Pillow: low on stock 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 7 8 9 10 } * Your code goes here */ return 0;arrow_forward3. Write a program that transforms numbers 1, 2, 3,..., 12 into the corresponding month names January, February, March, ..., December. Hint: Make a very long string "January February March ...", in which you add spaces such that each month name has the same length. Then use substring to extract the month you want.arrow_forwardplease code in python Write a function that receives a string and a number (n) as parameters and returns a new string that contains only every nth letter from the given string. print(everyNth('banana', 2)) # should return aaaprint(everyNth('carrot', 3)) # should return rtprint(everyNth('pear', 1)) # should return peararrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY