Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)
7th Edition
ISBN: 9780133862119
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 2.1, Problem 17STQ
Consider the following statement from the
System.out.println(originalAmount + “cents in coins can be given as:”);
Suppose that you replaced the preceding line with the following:
System.out.println(amount + “cents in coins can be given as:”);
How would this change the sample output given in Listing 2.3?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program whose input is two integers. Output the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer.
Ex: If the input is:
-15 10
the output is:
-15 -10 -5 0 5 10
Ex: If the second integer is less than the first as in:
20 5
the output is:
Second integer can't be less than the first.
Write a program whose input is two integers. Output the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer. You may prompt for the two integers as you wish; the prompt will not be included in the grading.
Ex: If the input is:
-15 21
the output is:
-15 -10 -5 0 5 10 15 20
Ex: If the second integer is less than the first as in:
20 5
the output is:
Second integer can't be less than the first.
For coding simplicity, output a space after every integer, including the last.
Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer. End with a newline.
Ex: If the input is:
-15 10
the output is:
-15 -10 -5 0 5 10
Ex: If the second integer is less than the first as in:
20 5
the output is:
Second integer can't be less than the first.
For coding simplicity, output a space after every integer, including the last.
Chapter 2 Solutions
Java: An Introduction to Problem Solving and Programming plus MyProgrammingLab with Pearson eText -- Access Card Package (7th Edition)
Ch. 2.1 - Prob. 1STQCh. 2.1 - Can a Java program have two different variables...Ch. 2.1 - Prob. 3STQCh. 2.1 - Give the declaration for two variables of type...Ch. 2.1 - Write the declaration for two variables called...Ch. 2.1 - What is the normal spelling convention for named...Ch. 2.1 - Prob. 7STQCh. 2.1 - Prob. 8STQCh. 2.1 - Prob. 9STQCh. 2.1 - Prob. 10STQ
Ch. 2.1 - Prob. 11STQCh. 2.1 - In the Programming Tip entitled Type Casting a...Ch. 2.1 - What is the output produced by the following lines...Ch. 2.1 - What is the output produced by the following lines...Ch. 2.1 - Prob. 15STQCh. 2.1 - Prob. 16STQCh. 2.1 - Consider the following statement from the program...Ch. 2.1 - Prob. 18STQCh. 2.2 - Prob. 19STQCh. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What output is produced by the following...Ch. 2.2 - What is the value of the expression sl.equals(s2)...Ch. 2.2 - What is the value of the expression s1.equals (s2)...Ch. 2.3 - Write Java statements that will cause the...Ch. 2.3 - What is the difference between the methods...Ch. 2.3 - Write a complete Java program that reads a line of...Ch. 2.3 - Write a complete Java program that reads one line...Ch. 2.3 - What output is produced by the following...Ch. 2.4 - Prob. 32STQCh. 2.4 - What is the output produced by the following Java...Ch. 2.4 - Although it is kind of silly, state legislatures...Ch. 2.5 - Prob. 35STQCh. 2.5 - Give a Java statement that will display a dialog...Ch. 2.5 - Give a Java statement that, when executed, will...Ch. 2.5 - Prob. 38STQCh. 2.5 - Write a complete Java program that produces a...Ch. 2.5 - Write a complete Java program that behaves as...Ch. 2 - Write a program that demonstrates the approximate...Ch. 2 - Write a program that demonstrates type casting of...Ch. 2 - Write a program that demonstrates the operator %...Ch. 2 - If u = 2, v = 3, w = 5, x = 7, and y = 11, what is...Ch. 2 - What changes to the ChangeMaker program in Listing...Ch. 2 - If the int variable x contains 10, what will the...Ch. 2 - Write some Java statements that use the String...Ch. 2 - Prob. 8ECh. 2 - Prob. 9ECh. 2 - Write a single Java statement that will display...Ch. 2 - What does the Java code Scanner keyboard = new...Ch. 2 - What does the Java code Scanner keyboard = new...Ch. 2 - Prob. 13ECh. 2 - Many sports have constants embedded in their...Ch. 2 - Prob. 15ECh. 2 - Define named constants that you could use in...Ch. 2 - Write a program that reads three whole numbers and...Ch. 2 - Write a program that uses Scanner to read two...Ch. 2 - Write a program that reads the amount of a monthly...Ch. 2 - Write a program that reads a four-digit integer,...Ch. 2 - Prob. 5PCh. 2 - Prob. 6PCh. 2 - Write a program that converts degrees from...Ch. 2 - Write a program that reads a line of text and then...Ch. 2 - Write a program that will read a line of text as...Ch. 2 - Write a program that asks the user to enter a...Ch. 2 - Write a program that determines the change to be...Ch. 2 - Write a program that reads a 4-bit binary number...Ch. 2 - Prob. 7PPCh. 2 - The Harris-Benedict equation estimates the number...Ch. 2 - Repeat any of the previous programming projects...Ch. 2 - Write a program that reads a string for a date in...Ch. 2 - It is important to consider the effect of thermal...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Modify the temperature conversion program to print a heading above the table.
C Programming Language
What is an object?
Starting Out With Visual Basic (8th Edition)
Write a for loop that repeats seven times, asking the user to enter a number. The loop should also calculate th...
Starting Out with Java: From Control Structures through Objects (6th Edition)
What makes Python an interpreted programming language?
Computer Science: An Overview (12th Edition)
What common programming language statement, in your opinion, is most detrimental to readability?
Concepts of Programming Languages (11th Edition)
Describe two properties that each candidate key must satisfy.
Modern Database Management (12th 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
- Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer. End with a newline. Ex: If the input is: -15 10 the output is: -15 -10 -5 0 5 10 Ex: If the second integer is less than the first as in: 20 5 the output is: Second integer can't be less than the first. For coding simplicity, output a space after every integer, including the last. given c code #include <stdio.h> int main(void) { /* Type your code here. */ return 0; }arrow_forwardWrite a program that exchanges the value of x and y. The output must be: the value of variable y and will become the value of variable x, and vice versaarrow_forwardWrite a program that reads in hours, minutes, as input, and outputs the time in minutes only.arrow_forward
- Write a Java program that will ask the user for a starting number, and ending number, and an increment number. The program will then count upward, from the starting number up to and including the ending number, by the increment number, displaying each number on a separate line. Also, for each displayed number, the program will say whether the number is even or odd. This program will require the use of the “while” loop as well as the “if/else” statement. Examine the sample outputs carefully in order to structure your code in a logical manner.Name the program Lab9.java Choose meaningful identifiers for all variables and constants Use blank lines here and there to separate logical steps in your code Use a one-line comment before each block to describe what you are doing – don’t describe the code syntax, but rather the purpose of the code. These comments should effectively describe the steps in your “algorithm.” Spell things carefully, including capitalization, since Java is fussy about…arrow_forwardWrite a Java program that will ask the user for a starting number, and ending number, and an increment number. The program will then count upward, from the starting number up to and including the ending number, by the increment number, displaying each number on a separate line. Also, for each displayed number, the program will say whether the number is even or odd. This program will require the use of the “while” loop as well as the “if/else” statement. Examine the sample outputs carefully in order to structure your code in a logical manner. Name the program Lab9.java Carefully read and adhere to the "coding standards" distributed in class Provide a comment block like the one in our Hello program Choose meaningful identifiers for all variables and constants Use blank lines here and there to separate logical steps in your code Use a one-line comment before each block to describe what you are doing – don’t describe the code syntax, but rather the purpose of the code. These comments…arrow_forwardWrite a Java program that will ask the user for a starting number, and ending number, and an increment number. The program will then count upward, from the starting number up to and including the ending number, by the increment number, displaying each number on a separate line. Also, for each displayed number, the program will say whether the number is even or odd. This program will require the use of the “while” loop as well as the “if/else” statement. Examine the sample outputs carefully in order to structure your code in a logical manner.Name the program Lab9.java Carefully read and adhere to the "coding standards" distributed in class Provide a comment block like the one in our Hello program Choose meaningful identifiers for all variables and constants Use blank lines here and there to separate logical steps in your code Use a one-line comment before each block to describe what you are doing – don’t describe the code syntax, but rather the purpose of the code. These comments…arrow_forward
- Write a program that reads in hours, minutes and seconds as input, and outputs the time in seconds only.arrow_forwardWrite a program in R studio that takes the weight of luggage as input from the user and prints the total amount the user needs to pay according to the given conditions: The user has to pay Tk.200 if the weight is 10kg or less. The user has to pay Tk.200 and an additional Tk.50 for every 1 kg over 10kg. Also, service charges are 5% of the total weight. The maximum weight of luggage is 30kg. Example 1: User Input: 5 Sample Output: Payment is: Tk. 200.25 Example 2: User Input: 20 Sample Output: Payment is: Tk. 701 Example 3: User Input: 32 Sample Output: The weight is crossing the maximum limitarrow_forwardWrite a program that does temperature converter :\n", "- The user will enter if he wants the result in Celsius or in Fahrenheit. Use the input function to read this option. \n", "- Ask the user the value of the temperature he wants to convert. Use the input function to read this value and convert accordingly.\n", "- If the user wants the temperature in Fahrenheit compute: $ Fahrenheit = Celsius*5/9+32$.\n", "- If the user wants the Celsius compute as follows: $ C = (F-32)*5/9 $.\n"arrow_forward
- Write a python program that does temperature converter :\n", "- The user will enter if he wants the result in Celsius or in Fahrenheit. Use the input function to read this option. \n", "- Ask the user the value of the temperature he wants to convert. Use the input function to read this value and convert accordingly.\n", "- If the user wants the temperature in Fahrenheit compute: $ Fahrenheit = Celsius*5/9+32$.\n", "- If the user wants the Celsius compute as follows: $ C = (F-32)*5/9 $.\n"arrow_forwardWhat would the output be from the following line: 6 + 4 / 2 5 8.0 8 5.0arrow_forwardWrite a program that takes a positive integer from the user and calculate the date from today. - Use the datetime python module to get today’s date - Use conditional statements to convert it to year, month and day in Gregorian calendar - Output: day of the week, week of the year, month, season and year. - **Assume all years have 365 days and all month have 30 days Sample input: >>> Today is February 22, 2022 >>> Enter a positive integer: 2535 Sample output: Year: 2029 Month and Season: January, Winter Week of the year: 5th week of the year Day of the week: Wednesday (If normal calendar rules) In the United States: 1/31/2029, anywhere else in the world 31/1/2029arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Introduction to Operators in C; Author: Neso Academy;https://www.youtube.com/watch?v=50Pb27JoUrw;License: Standard YouTube License, CC-BY