Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 5, Problem 5.21PE
Program Plan Intro
Financial Application
Program Plan:
- Define the class
- Define the main method using public static main.
- Declare and initialize the required variable.
- Prompt the user to enter loan amount and number of years.
- Read the inputs
- Using for loop,
- Calculate monthly interest rate.
- Calculate monthly payment amount.
- Calculate total payment amount.
- Display the results on the screen.
- Define the main method using public static main.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Q1) Write a program that
• Asks for a natural number (Assume that number is n)
• Draws the following triangular shape with n lines of numbers.
Example:
(n = 5)
1.
2 1
3 21
4 3 2 1
5 4 3 21
(n = 3)
1.
21
3 21
In the triangular shape,
There is a space character between each neighboring numbers on the same line.
• The rightmost number is supposed to be 1.
• The numbers are ordered in a descending order.
The ith line should contain i numbers.
The numbers are aligned right.
2.31 (Table of Squares and Cubes) Using only the programming techniques you learned in this
chapter, write an application that calculates the squares and cubes of the numbers from 0 to 10 and
prints the resulting values in table format, as shown below.
number square
0
0
1
1
2
4
3
4
5
6
7
8
9
10
9
16
25
36
49
64
81
100
cube
0
1
8
27
64
125
216
343
512
729
1000
compare loans with various interest rates) Write a programthat lets the user enter the loan amount and loan period in number of years anddisplays the monthly and total payments for each interest rate starting from 5% to10%, with an increment of 1/4. Here is a sample run:
Loan Amount: 10000Number of Years: 5Interest Rate Monthly Payment Total Payment5.000% 188.71 11322.745.250% 189.86 11391.595.500% 191.01 11460.70...9.750% 211.24 12674.5510.000% 212.47 12748.23
Chapter 5 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Ch. 5.2 - Prob. 5.2.1CPCh. 5.2 - How many times are the following loop bodies...Ch. 5.2 - Prob. 5.2.3CPCh. 5.3 - What is wrong if guess is initialized to 0 in line...Ch. 5.4 - Revise the code using the System. nanoTime () to...Ch. 5.5 - Prob. 5.5.1CPCh. 5.6 - Prob. 5.6.1CPCh. 5.6 - What are the differences between a while loop and...Ch. 5.7 - Do the following two loops result in the same...Ch. 5.7 - What are the three parts of a for loop control?...
Ch. 5.7 - Suppose the input is 2 3 4 5 0. What is the output...Ch. 5.7 - What does the following statement do? for ( ; ; )...Ch. 5.7 - If a variable is declared in a for loop control,...Ch. 5.7 - Convert the following for loop statement to a...Ch. 5.7 - Count the number of iterations in the following...Ch. 5.8 - Can you convert a for loop to a while loop? List...Ch. 5.8 - Can you always convert a while loop into a for...Ch. 5.8 - Identify and fix the errors in the following code:...Ch. 5.8 - Prob. 5.8.4CPCh. 5.9 - How many times is the println statement executed?...Ch. 5.9 - Show the output of the following programs. (Hint:...Ch. 5.11 - Will the program work if n1 and n2 are replaced by...Ch. 5.11 - In Listing 5.11. why is it wrong if you change the...Ch. 5.11 - In Listing 5. 11, how many times the loop body is...Ch. 5.11 - Prob. 5.11.4CPCh. 5.11 - Prob. 5.11.5CPCh. 5.12 - What is the keyword break for? What is the keyword...Ch. 5.12 - The for loop on the left is converted into the...Ch. 5.12 - Rewrite the programs TestBreak and TestContinue in...Ch. 5.12 - After the break statement in (a) is executed in...Ch. 5.13 - What happens to the program if (low high) in line...Ch. 5.14 - Simply the code in lined 27-32 using a conditional...Ch. 5 - (Count positive and negative numbers and compute...Ch. 5 - (Repeat additions) Listing 5.4,...Ch. 5 - (Conversion from kilograms to pounds) Write a...Ch. 5 - (Conversion from miles to kilometers) Write a...Ch. 5 - (Conversion from kilograms to pounds and pounds to...Ch. 5 - Prob. 5.6PECh. 5 - (Financial application: compute future tuition)...Ch. 5 - (Find the highest score) Write a program that...Ch. 5 - (Find the two highest scores) Write a program that...Ch. 5 - (Find numbers divisible by 5 and 6) Write a...Ch. 5 - (Find numbers divisible by 5 or 6, but not both)...Ch. 5 - (Find the smallest n such that n2 12,000) Use a...Ch. 5 - (Find the largest n such that n3 12,000) Use a...Ch. 5 - (Compute the greatest common divisor) Another...Ch. 5 - (Display the ASCII character table) Write a...Ch. 5 - (Find the factors of an integer) Write a program...Ch. 5 - (Display pyramid) Write a program that prompts the...Ch. 5 - (Display four patterns using Loops) Use nested...Ch. 5 - (Display numbers in a pyramid pattern) Write a...Ch. 5 - (Display prime numbers between 2 and 1,000) Modify...Ch. 5 - Prob. 5.21PECh. 5 - For the formula to compute monthly payment, see...Ch. 5 - (Demonstrate cancellation errors) A cancellation...Ch. 5 - Prob. 5.24PECh. 5 - (Compute ) You can approximate by using the...Ch. 5 - (Compute e) You can approximate e using the...Ch. 5 - (Display leap years) Write a program that displays...Ch. 5 - (Display the first days of each month) Write a...Ch. 5 - (Display calendars) Write a program that prompts...Ch. 5 - (Financial application: compound value) Suppose...Ch. 5 - (Financial application: compute CD value) Suppose...Ch. 5 - (Game: lottery) Revise Listing 3.8, Lottery.java,...Ch. 5 - (Perfect number) A positive integer is called a...Ch. 5 - (Game: scissor; rock, paper) Programming Exercise...Ch. 5 - (Summation) Write a program to compute the...Ch. 5 - (Business application: checking ISBN) Use loops to...Ch. 5 - (Decimal to binary) Write a program that prompts...Ch. 5 - (Decimal to octal) Write a program that prompts...Ch. 5 - (Financial application: find the sales amount) You...Ch. 5 - (Simulation: heads or tails) Write a program that...Ch. 5 - (Occurrence of max numbers) Write a program that...Ch. 5 - (Financial application: find the sales amount)...Ch. 5 - (Math: combinations) Write a program that displays...Ch. 5 - (Computer architecture: bit-level operations) A...Ch. 5 - (Statistics: compute mean and standard deviation)...Ch. 5 - (Reverse a string) Write a program that prompts...Ch. 5 - (Business: check ISBN-13) ISBN -13 is a new...Ch. 5 - (Process string) Write a program that prompts the...Ch. 5 - (Count vowels and consonants) Assume that the...Ch. 5 - Prob. 5.50PECh. 5 - (Longest common prefix) Write a program that...
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
- Spring 2020-2021 Question2 (50 pts) Write a program that reads from the user a character ('q' or 'c'). • If the character is 'c', the program reads from the user the ra dius r of a circle and prints its area. If the user enters 'q', the program asks the user to enter the length and width of a quadrilateral. We assume the quadrilateral is either a square or rectangle. You should print if the quadrilateral is square or rectangle. • Otherwise, it prints "Wrong character" PS: Use the following formulas : area of circle=3.14*r? Sample Runl: Enter a character (q or c): q Enter the Length and Width: 80 150 It is a rectangle Sample Run2: Enter a character (q or c): q Enter the Length and Width: 80 80 It is a square Q + Page 3 / 3arrow_forward2.16 LAB: Musical note frequencies On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency of fO * r^, where n is the distance (number of keys) from that key, and r is 20/12) Given an initial key frequency, output that frequency and the next 4 higher key frequencies.arrow_forward3.6 LAB: Number pattern Write a recursive function called print_num_pattern() to output the following number pattern. Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached. For coding simplicity, output a space after every integer, including the last. Do not end output with a newline. Ex. If the input is: 12 3 the output is: 12 9 6 3 0 3 6 9 12arrow_forward
- 3.6 LAB: Number pattern Write a recursive function called print_num_pattern() to output the following number pattern. Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached. For coding simplicity, output a space after every integer, including the last. Do not end output with a newline Ex. If the input is: 12 3 the output is 12 9 6 3 0 3 6 9 12 0/10 LAB ACTIVITY 3.6.1: LAB: Number pattern main.py Load default template 1. TODO: Write recursive print_num_pattern() function 2 3 if name "main": 4 numi int(input()) 5 num2 int(input()) print_num_pattern(num, num2)arrow_forwardPlease read instructions carefully:arrow_forwardcode in c# consolearrow_forward
- ***Microsoft Visual Studios (C++)*** Write a program that given two coordinate pairs and a third single coordinate will linearly interpolate or extrapolate the third second coordinate. For example, let's say at 50 degrees Celsius the length of a metal rod is 5.4 cm and at 60 degrees Celsius the length is 5.5cm. I can interpolate the length at 53 degrees Celsius by doing 5.4cm + 3*(.1/10)=5.43cm. Your program does not need to continuously run, but should prompt the user for two coordinate pairs, the third first coordinate and return the extrapolated or interpolated third second coordinate.arrow_forward24) / Fill in the blank (no space between the digits) the octal expansion of the number that succeeds (4277) ( 25) (( Fill in the blank (no space between the digits) the hexadecimal expansion of the number that precedes (E20)1 .)15 Convert from the hexadecimal expansion (3FB5E) to the oxtal expansion. 10 26) f 27) (0 Convert from the octal expansion (77654) to the hexadecimal expansion. .)16arrow_forward***Java*** 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.arrow_forward
- 6.6 LAB: File name change Instructor note: You can easily replace a portion of text within a String using the String method "replace()". For example: String svar = "raspberry jam"; svar = svar.replace("jam", "pie"); System.out.println(svar); will print out: raspberry pie A photographer is organizing a photo collection about the national parks in the US and would like to annotate the information about each of the photos into a separate set of files. Write a program that reads the name of a text file containing a list of photo file names. The program then reads the photo file names from the text file, replaces the "_photo.jpg" portion of the file names with "_info.txt", and outputs the modified file names. Assume the unchanged portion of the photo file names contains only letters and numbers, and the text file stores one photo file name per line. If the text file is empty, the program produces no output. Ex: If the input of the program is: ParkPhotos.txt and the contents of…arrow_forward6.19 LAB: Leap year - functions A common year in the modern Gregorian Calendar consists of 365 days. In reality, Earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days. An extra day, February 29th. The requirements for a given year to be a leap year are 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400, therefore, both 1700 and 1800 are not leap years Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines the number of days in February for that year Ex. If the input is 1712 the output is 1712 has 29 days in February. Ex If the input is 1913 the output is 1913 has 28 days in February. Your program must define and call the following function. The function should return the number of days in February for the input year. def days in feb(user_year)arrow_forwardQ4) Write program, to allow the user to enter the height, and width of any rectangle, and find the area. area= height*width Q5) ) Write program , to allow the user to enter the height, and base of any triangle, the find the area. Q6) Write program, to allow the user to enter the radius of any circle, and find the area of this circle. Note : area= pi*(n*n)arrow_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