Question
The pseudocode below has been written as an algorithmic solution to the following programming task but is not complete and may include some incorrect logic.
The pseudocode below has been written as an algorithmic solution to the following programming task but is not complete and may include some incorrect logic. Complete the pseudocode to incorporate all aspects of the following programming task and ensure that the output is correct before writing the Java source code.
In the fire swamp located between Florin and Guilder, Rodents of Unusual Size roam. They are just one of the three dangers that travelers must overcome if they are to survive their journey through the swamp. A program that will predict the size of a population of Rodents of Unusual Size over time (years). The program should ask for the starting number of Rodents of Unusual Size, their average annual population increase (as a percentage), and the number of years they will multiply. For example, a population of Rodents of Unusual Size might begin with 400, have an average annual increase of 2 percent, and be allowed to multiply for twelve years. The program must display the predicted size of the Rodents of Unusual Size population for each year.
Do not accept a number less than 300 for the initial size of the population. Do not accept a negative number for average annual population increase (note: average annual
population increase already includes deaths due to old age, disease, predatory hunting (not likely), natural disasters, flame spurts, and encounters with Westley, etc). Do not accept a number less than 10 for the number of years the population will multiply. The Scanner class must be used for keyboard input. Arrays or arraylists are not to be used in this program.
Initial pseudocode prompt 'enter the initial population of Rodents of Unusual Size get initial population prompt 'enter annual population increase percentage' get percentage increase prompt 'enter number of years to estimate population' get number of years.
for each year
display year, population
population = population + population * increase/100
Note: Correct the initial pseudocode/algorithm for the problem, then write and test the Java source code
2. Book Shop.
At the local bookshop, customers can select and purchase books by visiting the shop. They can browse the shelves, choose their desired books, and place them in their physical shopping basket. After selecting the books they want to buy, customers proceed to the sales desk to make payment. The sales assistant enters the price and quantity for each book in the shopping basket. The cash register then calculates the total due for all the books being purchased by the customer. Once the total cost is calculated, the customer can choose to pay using one of two payment methods: cash, or credit card. After payment has been finalised an on-screen receipt is displayed.
Write a Java program that will enable shopping transactions as described above and will continue until the user chooses to end it, allowing multiple customers to make transactions. The program should validate all user input, ensuring that book prices, quantities, and payment amounts are not negative or zero, and that only the two payment types are allowed.
The output of the receipt will vary depending on the chosen payment method(s) and should only display the details of the payment method(s) chosen by the customer (see example receipts below).
The Scanner class must be used for keyboard input. Arrays or array lists are not to be used in this program.
Payment rules:
• If the customer chooses to pay for the transaction by credit card, the total cost of the books is charged to the credit card.
• If the customer chooses to pay for the transaction by cash, but the cash tendered is insufficient for the total cost of the books, the remainder of the total cost must be paid for by credit card, or the customer may cancel the transaction (the customer's choice).
• When any part of a customer transaction is paid by credit card, there is no need for the entry of credit card information (assume this is known from scanning the credit card).
Note: The receipt should look similar to the following example output, i.e., it does not need to be identical
Example Receipt output when paid by Cash with
insufficient payment:
Purchase Summary
=====================================
Total Due: $ 190.75
-------------------------------------
Cash Payment: $ 50.00
Credit Card Payment: $ 140.75
Owing: $ 0.00
=====================================
Example Receipt output when paid by Cash with
sufficient payment:
Purchase Summary
=====================================
Total Due: $ 190.75
-------------------------------------
Cash Payment: $ 200.00
Change: $ 9.25
Owing: $ 0.00
=====================================
Example Receipt output when paid by Credit Card:
Purchase Summary
=====================================
Total Due: $ 190.75
-------------------------------------
Credit Card Payment: $ 190.75
Owing: $ 0.00
=====================================
Note: Plan a solution by producing an IPO chart and an initial algorithm for the problem, then write and test the Java source code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Heres the completed pseudocode for the Rodents of Unusual Size population prediction program aenter ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started