Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
11th Edition
ISBN: 9780134671710
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 17, Problem 17.6PE
Program Plan Intro
Store Loan objects
Program Plan:
Loan.java
- Definition for the class “Loan”.
- Declare the required variables.
- Create default constructor
- Pass the object through the constructor.
- Create the parameterized constructor.
- Assign annual interest rate, number of years, loan amount and date.
- Definition for the method “getAnnualInterestRate()”.
- Return “annualInterestRate”.
- Definition for the method “getAnnualInterestRate()”.
- Return the “getAnnualInterestRate”.
- Definition for method “setAnnualInterestRate()”
- Return the annual Interest Rate.
- Definition for method “getNumberOfYears()”
- Return the number of years.
- Definition for method “setNumberOfYears()”.
- Return the loan amount.
- Definition for method “setLoanAmount()”.
- Assign the number of years”.
- Definition for method “getTotalPayment()”
- Calculate the monthly interest rate.
- Calculate the monthly payment.
- Return monthly payment.
- Definition for method “getTotalPayment”.
- Calculate the total payment.
- Return total payment.
- Definition for “LoanDate()”.
- Return the loan date.
Amount.java
- Import required packages.
- Definition for the class “Amount”.
- Definition for main class.
- Create five objects for loan to store it in the file.
- Write the entire loan object to the file named “Exercise17_0.6.dat”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Select the statement that is false regarding file guarding.
Group of answer choices:
In your .h files all code should be contained within the guards.
It restricts the scope of a namespace, which prevents namespace pollution.
If used properly it prevents redefinitions of classes/functions.
It is an instruction to the preprocessor.
It must make use of a unique identifier.
(Intro to Java)
Tracking Customers
This program will read in a series of names, along with an associated gender, from an input file of unknown length.
The program uses a while loop to read in each name from the file by using the hasNextLine() method from the Scanner class.
Please use a while loop for practice, although you could also write this assignment using a for loop to read from the file.
As you read in each name, you will store it in an array, along with a title (Mr. or Ms. or Mx.) dependent on the stated gender.
The first line of each file will contain the number of names contained in the file (hint: this is the same structure as the input file in your assignment 18.2).
Additionally, this program should have two methods, as follows:
The first method:
The method is named extractInitial
It takes a String parameter
It extracts the first letter (initial) from the String parameter
It returns a char for the initial.
Note: You must write a complete Javadoc for this method to…
(Creating Custom Exception Class) Write a Password class that stores a password string. Passwords must contain at least seven alpha-numeric characters, with at least one letter and one digit. Also write an InvalidPasswordException class that extends Exception. The Password constructor should throw an InvalidPasswordException, which should report an appropriate message based on a given string (e.g. if the string contains no digits, the exception should report this fact). Write a GUI program to prompt the user to enter a password and report an InvalidPasswordException if an invalid password is entered. Please teach and help me how to deisgn the program based on the two files given .Some sample screenshots are shown below:
InvalidPasswordException.java
public class InvalidPasswordException extends Exception{ public InvalidPasswordException (String errMsg){ super(errMsg); } }
Password.java
public class Password {private String passwordstr;
public…
Chapter 17 Solutions
Introduction to Java Programming and Data Structures: Brief Version (11th Global Edition)
Ch. 17.2 - What is a text file and what is a binary file? Can...Ch. 17.2 - How do you read or write text data in Java? What...Ch. 17.3 - Prob. 17.3.1CPCh. 17.3 - How is a Java character represented in the memory,...Ch. 17.3 - If you write the string ABC to an ASCII text file,...Ch. 17.3 - If you write the string 100 to an ASCII text file,...Ch. 17.3 - What is the encoding scheme for representing a...Ch. 17.4 - Prob. 17.4.1CPCh. 17.4 - Why should you always close streams? How do you...Ch. 17.4 - Prob. 17.4.3CP
Ch. 17.4 - Does FileInputStream/Fi1eOutputStream introduce...Ch. 17.4 - What will happen if you attempt to create an input...Ch. 17.4 - How do you append data to an existing text file...Ch. 17.4 - Prob. 17.4.7CPCh. 17.4 - What is written to a file using writeByte(91) on a...Ch. 17.4 - How do you check the end of a file in an input...Ch. 17.4 - What is wrong in the following code? Import...Ch. 17.4 - Suppose you run the following program on Windows...Ch. 17.4 - After the following program is finished, how many...Ch. 17.4 - For each of the following statements on a...Ch. 17.4 - What are the advantages of using buffered streams?...Ch. 17.5 - How does the program check if a file already...Ch. 17.5 - How does the program detect the end of the file...Ch. 17.5 - How does the program count the number of bytes...Ch. 17.6 - Prob. 17.6.1CPCh. 17.6 - Prob. 17.6.2CPCh. 17.6 - Is it true that any instance of...Ch. 17.6 - Prob. 17.6.4CPCh. 17.6 - Prob. 17.6.5CPCh. 17.6 - What will happen when you attempt to run the...Ch. 17.7 - Can RandomAccessFi1e streams read and write a data...Ch. 17.7 - Create a RandomAccessFi1e stream for the file...Ch. 17.7 - What happens if the file test.dat does not exist...Ch. 17 - (Create a text file) Write a program to create a...Ch. 17 - (Create a binary data file) Write a program to...Ch. 17 - (Sum all the integers in a binary data file)...Ch. 17 - (Convert a text file into UTF) Write a program...Ch. 17 - Prob. 17.5PECh. 17 - Prob. 17.6PECh. 17 - Prob. 17.7PECh. 17 - (Update count) Suppose that you wish to track how...Ch. 17 - (Address book) Write a program that stores,...Ch. 17 - (Split files) Suppose you want to back up a huge...Ch. 17 - (Split files GUI) Rewrite Exercise 17.10 with a...Ch. 17 - Prob. 17.12PECh. 17 - (Combine files GUI) Rewrite Exercise 17.12 with a...Ch. 17 - (Encrypt files) Encode the file by adding 5 to...Ch. 17 - (Decrypt files) Suppose a file is encrypted using...Ch. 17 - (Frequency of characters) Write a program that...Ch. 17 - (BitOutputStream) Implement a class named...Ch. 17 - (View bits) Write the following method that...Ch. 17 - (View hex) Write a program that prompts the user...Ch. 17 - (Hex editor) Write a GUI application that lets the...
Knowledge Booster
Similar questions
- Description: Create (Java Program) a phonebook directory that will store the contact numbers of N persons. Your program should allow the user to add, view, delete, and update the contacts in the phonebook. Note that one person can have multiple contact numbers. The program will stop when the user command is ‘X’. Program command and entry should not be case-sensitive. That means commands ‘I’ or ‘i’ and the name “Jacky” or “JACKY” are the same. Each contact number can be 7 digits or 11 digits only. The user should input a string containing the command, name, and contact number(s) (Limit the contact number of each person to three). This string should be broken down into fields in order to separate the different values and store them in their appropriate variables. Use linked list in the implementation. Your node must declare at least four instance variables. Program flow: Command> I Jacky 09211234567 Remarks: New contact has been added. Command> V Jacky Contact Number(s):…arrow_forward(Remove text) Write a program that removes all the occurrences of a specified string from a text file. (For example, my mother went to buy groceries while John and I play Call of duty.) removes the string John from the file. You should create a file with a paragraph. removes the string "John and" from the file. Note:- Please write a java code and also need an output for this program. (Also, let me know with what name file should be saved to get output)arrow_forward(TicTacToe Class) Create a class TicTacToe that will enable you to write a complete programto play the game of tic-tac-toe. The class contains as private data a 3-by-3 two-dimensional arrayof integers. The constructor should initialize the empty board to all zeros. Allow two human players.Wherever the first player moves, place a 1 in the specified square. Place a 2 wherever the second player moves. Each move must be to an empty square. After each move, determine whether the gamehas been won or is a draw. If you feel ambitious, modify your program so that the computer makesthe moves for one of the players. Also, allow the player to specify whether he or she wants to go firstor second. If you feel exceptionally ambitious, develop a program that will play three-dimensionaltic-tac-toe on a 4-by-4-by-4 board. [Caution: This is an extremely challenging project that couldtake many weeks of effort!]arrow_forward
- Exercise 1. (Spell Checker) Write a program spell_checker.py that accepts words from standard input; looks up each word in the file data/misspellings.txt that maps misspelled words to their correct spellings; and if it exists (ie, is misspelled), writes the word to standard output along with the correct spelling. >- "/workspace/project6 $ python3 spell_checker.py Try nto to become a man of sucess but rather try to become man of value. * Albert Einstein nto -> not sucess -> success E spell.checker.py from instream import InStream from symboltable import SymbolTable import stdio # Entry point. def main (): # Set inStream to an input stream built from the file 'data/misspellings.txt'. # Set lines to the list of lines read from inStream. .. # Set misspellings to a new symbol table object. .. for in ...: # For each line (of the form 'misspelling correction ') in lines... # Set tokens to the list obtained by splitting line using the split () method from str. # Insert the pair tokens…arrow_forward(True/False): The ReadConsole function reads mouse information from the input bufferarrow_forward(Sort three numbers) Write the following function to display three numbers in increasing order: def displaySortedNumbers(num1, num2, num3): Write a test program that prompts the user to enter three numbers and invokes the function to display them in increasing order. Here are some sample runs:arrow_forward
- (Intro to Java) explain the answers to the below questions using step-by-step explanation. Assume you have a text file named in.txt with the following contents: All what-ifsAnd what can’t be,I cast them out;Now I am free. -Ms Moem Given Code: File file = new File("in.txt");Scanner input = new Scanner(file);int count = 1;while(input.hasNext()) {String str = input.next();System.out.println(count + ": " + str);count++;}input.close(); Given the code above, add some additional lines of code to write value of count to an output file named count.txt. And, run the code to verify you get the right output to receive full credit. Note that you must run this code without changing the first line of the starter code. File file = new File("in.txt");Scanner input = new Scanner(file);int count = 1;while(input.hasNext()) {String str = input.next();System.out.println(count + ": " + str);count++;}input.close();//Add your lines of code here!arrow_forward(Convert decimals to fractions)Write a program that prompts the user to enter a decimal number and displays the number in a fraction.Hint: read the decimal number as a string, extract the integer part and fractional part from the string, and use the Rational class in LiveExample 13.13 to obtain a rational number for the decimal number. Use the template athttps://liveexample.pearsoncmg.com/test/Exercise13_19.txt The problem can not use BigInteger //Below is the Rational LiveExample 13.13 that goes with the problem/question; notice "long" instead of "BigInteger" class Rational extends Number implements Comparable<Rational> { // Data fields for numerator and denominator private long numerator = 0; private long denominator = 1; /** Construct a rational with default properties */ public Rational() { this(0, 1); } /** Construct a rational with specified numerator and denominator */ public Rational(long numerator, long denominator) { long gcd = gcd(numerator,…arrow_forward(In java) Lab6C: Cha-Ching For this lab, use a do-while loop.A sentinel loop is a loop (a special while loop or a do-while loop) that continues to process data until itreaches a specific value(s) that signals that it should stop looping; this special value(s) is usuallyindicated as the condition of the while or do-while loop. A good example of a sentinel loop is the whileloop that you had to write to verify user input in Lab6B, the special values were anything in the range of1 to 1000. Another very common application for this is allowing a user to rerun a program.Please write a very simple program that mimics a bank account. The program should start the user outwith $1000. The program should print out a welcome menu once with the options present for the user.The program should allow the user to make a deposit, withdrawal, and see their current balance.Every time the user deposits or withdraws, the program should show the user their new balance; itshould also ask the user if they want…arrow_forward
- (Intro to Java) Only use while loop or for loop. DO NOT use try loop! DO NOT use null. Avoid using breaks! Tracking Customers This program will read in a series of names, along with an associated gender, from an input file of unknown length. The program uses a while loop to read in each name from the file by using the hasNextLine() method from the Scanner class. Please use a while loop for practice, although you could also write this assignment using a for loop to read from the file. As you read in each name, you will store it in an array, along with a title (Mr. or Ms. or Mx.) dependent on the stated gender. The first line of each file will contain the number of names contained in the file (hint: this is the same structure as the input file in your assignment 18.2). Additionally, this program should have two methods, as follows: The first method: The method is named extractInitial It takes a String parameter It extracts the first letter (initial) from the String parameter It…arrow_forward(Intro to Java) Open a new Java file called ArrayMethods.java. Read the Javadoc comment for each method below and write the method according to the description in the comment Once you are getting the correct output for all tests inside of main, upload your source file to Canvas public class ArrayMethods { /** * Displays the contents of an array on the console * with each element separated by a blank space * Prints a new line character last * @param nums the array to print to the console */ public static void printArray(int[] nums) { return; } /** * Assuming an array of integers, return true if 1 * is the first element or 1 is the last element * Note: you may assume that you will be given an array * of at least length 1 * is1FirstLast([1, 2, 10]) → true * is1FirstLast([10, 1, 2, 1]) → true * is1FirstLast([13, 10, 1, 2, 3]) → false * @param numbers the array of int numbers * @return whether or not 1 is the first or…arrow_forward(True/False): An Object file is produced by the Linkerarrow_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