QuestionQuestion

Description
The holidays are upon us and your friends have once again started complaining about the stress of getting their holiday shopping done within their budgets. As a budding and altruistic code wizard, you are determined to help by writing a Java program that will allow your friends to plan and manage their gift purchases.
The description of how the user interacts with the program (the user story) is as follows:

A message on the screen welcomes the user to the holiday gift planner and the program briefly explains its purpose. The program then prompts the user to enter the number of gifts they need to purchase this holiday season followed by the user’s maximum total gift budget. To help the user plan each gift the program then displays the average amount budgeted per gift as a guide to the gift planning. Next, the user is prompted to enter three pieces of information for each gift: 1) a short description of the gift, 2) the price of the gift, and 3) the name of the person who will receive the gift. After this, the program displays a numbered list of all the gift information including a statement about whether each gift is above or below the average amount budgeted per gift. It also reports the total price of all the gifts, the amount of the sales tax (13% of the total price) and the total price with the sales tax added. Furthermore, it warns the user if this total price (with sales tax) is greater than the total budgeted. Next, the user is prompted to enter the list number of a gift that needs changes. The user is prompted to enter a new description, price and name for the gift, but can simply press enter at each prompt to avoid changing the specific field. The numbered gift list and totals are then redisplayed with the updated information and the user is again prompted for the number of a gift to edit. This process of displaying the gift list and making changes continues until the user is satisfied with the gift information and enters a gift number of 0 (zero) to exit the program.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

public class HolidayGiftPlanner {

// Method to print report of gifts as a table
public static void printGiftsReport(String[] descriptions, double[] prices, String[] names, double averageBudget) {
    System.out.format("%4s %12s %25s %12s %25s \n", " #.", "For", "Gift", "Price", "Over/Under Average");
    System.out.format("%4s %12s %25s %12s %25s \n", "---", "---", "----", "-----", "------------------");
    for (int i = 0; i < descriptions.length; i++) {
      if (prices[i] <= averageBudget) {
       System.out.format("%4s %12s %25s %12s %25s \n", (i+1)+".", names[i], descriptions[i], String.format("$%.2f", prices[i]), "under");
      } else {
       System.out.format("%4s %12s %25s %12s %25s \n", (i+1)+".", names[i], descriptions[i], String.format("$%.2f", prices[i]), "over");
      }
    }
}

// Method to get total price from array of prices
public static double getTotal(double[] prices) {
    double total = 0.0;
    for (double price: prices) {
      total += price;
    }
    return total;
}

// Method to calculate sales tax from a total
public static double calculateSalesTax(double total) {
    return total*0.13;
}...

By purchasing this solution you'll be able to access the following files:
Solution.java.

50% discount

Hours
Minutes
Seconds
$45.00 $22.50
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats