First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).Then create a new Java application called "ECommerceApp" (without the quotation marks) whose main method follows the pseudocode below, and whose other methods are as specified below.Print the banner messageGet the products catalog StringGet the product order from the user and check if it exists in the products catalog StringIf the product existsGet the product priceCompute the product taxCompute the total saleOutput the total saleElseOutput "The product was not found."Your program must include the following methods:A method called bannerPrinter that takes no parameter and has no return value. bannerPrinter outputs a greeting to the command line as shown below. [CASE 1] ******************************************====== Welcome to my eCommerce app! ======******************************************(print a blank line after the banner)A method called productsBuilder that takes no parameters and returns a String. In the method body construct a String (name it productsCatalog) and populate it with items, each of which must be 10 characters long. For any product less than 10 characters, pad the remainder with spaces. You don't need to get the values from the user, just populate the String with 3 product names. For example, product 1 might be "Desk ", product 2 might be "Table ", and product 3 might be "Pen ". All 3 of these products are within the productsCatalog String. [CASE 2] productsCatalog = "item " + "book " + "cassette "; // size of string = 30A method called getOrder that takes a String as a parameter (the productsCatalog String) and returns a boolean. In the method body, prompt the user to enter a product name (a String), then check whether the product name exists in productsCatalog. If it exists, return true, otherwise return false. [CASE 4] A method called getPrice that returns a double and takes no parameters. In the method body generate a random number between 1 and 100 (Hint: See Horstmann Section 4.9.2.) and return this value as the price. [CASE 2] A method called getTax that takes a double as a parameter (the price) and returns a double. Compute the return value as 10% of the parameter value (i.e. 10% of the price). This is the tax. [CASE 4] A method called getTotal that takes two doubles as parameters (the price and the tax) and returns a double. The return value is computed as the sum of the two parameters (the return value is the sale total). [CASE 4] A method called printTotal that takes a double as a parameter (the sale total) and has no return value. This method outputs the following to the command line: "Your sale total is: $X" where X is the sale total parameter value. [CASE 3] All currency amounts that your program outputs should show a leading "$" followed by the whole number, a decimal, and two decimal positions.

Question
Asked Nov 8, 2019
190 views

First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).
Then create a new Java application called "ECommerceApp" (without the quotation marks) whose main method follows the pseudocode below, and whose other methods are as specified below.

Print the banner message
Get the products catalog String
Get the product order from the user and check if it exists in the products catalog String
If the product exists
Get the product price
Compute the product tax
Compute the total sale
Output the total sale
Else
Output "The product was not found."
Your program must include the following methods:
A method called bannerPrinter that takes no parameter and has no return value. bannerPrinter outputs a greeting to the command line as shown below. [CASE 1]
******************************************
====== Welcome to my eCommerce app! ======
******************************************
(print a blank line after the banner)

A method called productsBuilder that takes no parameters and returns a String. In the method body construct a String (name it productsCatalog) and populate it with items, each of which must be 10 characters long. For any product less than 10 characters, pad the remainder with spaces. You don't need to get the values from the user, just populate the String with 3 product names. For example, product 1 might be "Desk ", product 2 might be "Table ", and product 3 might be "Pen ". All 3 of these products are within the productsCatalog String. [CASE 2]
productsCatalog = "item " + "book " + "cassette "; // size of string = 30
A method called getOrder that takes a String as a parameter (the productsCatalog String) and returns a boolean. In the method body, prompt the user to enter a product name (a String), then check whether the product name exists in productsCatalog. If it exists, return true, otherwise return false. [CASE 4]

A method called getPrice that returns a double and takes no parameters. In the method body generate a random number between 1 and 100 (Hint: See Horstmann Section 4.9.2.) and return this value as the price. [CASE 2]

A method called getTax that takes a double as a parameter (the price) and returns a double. Compute the return value as 10% of the parameter value (i.e. 10% of the price). This is the tax. [CASE 4]

A method called getTotal that takes two doubles as parameters (the price and the tax) and returns a double. The return value is computed as the sum of the two parameters (the return value is the sale total). [CASE 4]

A method called printTotal that takes a double as a parameter (the sale total) and has no return value. This method outputs the following to the command line: "Your sale total is: $X" where X is the sale total parameter value. [CASE 3]
All currency amounts that your program outputs should show a leading "$" followed by the whole number, a decimal, and two decimal positions.

check_circle

Expert Answer

Step 1

A Java program for the given scenario is provided below,

File name: “ECommerceApp.java”

//Import required package

import java.util.Random;

import java.util.Scanner;

//Create a class

public class ECommerceApp

{

     //Define a function

     public static String productsBuilder ()

     {

          //Return product catalog

          return "item ,book ,cassette ";

     }

     //Define the function

     public static boolean getOrder(String name)

     {

          //Return the value returned from productsBuilder()

          return productsBuilder().contains(name);

     }

     //Define a function

     public static double getPrice()

     {

          //Create object for Random class

          Random rand = new Random();

          /*Return the random price calculated using random value*/

          return rand.nextInt((100 - 1) + 1) + 1;

     }

     //Define a function

     public static double getTax(double price)

     {

          //Return 10 % tax of price

          return (price*10.0)/100.0;

     }

     //Define a function

     public static double getTotal(double price, double tax)

     {

          //Return the total sale

          return price+tax;

     }

     //Define a function

     public static void printTotal(double total)

     {

          //Print the formatted output

          System.out.println(String.format("Your sale Total is $%.2f", total));

     }

     //Define the main() method

     public static void main(String[] args)

     {

          //print banner

          System.out.println("******************************************\r\n"

                   + "====== Welcome to my eCommerce app! ======\r\n" +

                   "******************************************"); 

          //Assign the value returned from productsBuilder()

          String productsCatalog = productsBuilder();

          //Prompt the user to enter the product for order

          System.out.print("Enter the product name for order : ");

          //Assign the order get from the user

          String ordername = new Scanner(System.in).next();

          //Execute "if" for the order entered

          if(getOrder(ordername))

          {

              //Assign the price returned from getPrice()

              double price = getPrice();

              //Assign the tax returned from getTax()

              double tax= getTax(price);

              //Assign the total sale returned from the getTotal()

              double total_sale= getTotal(price, tax);

              //Call the function to print the total sale

              printTotal(total_sale);

          }

          //Otherwise

          else

              //Print the string

              System.out.println("The product was not found.");

     }

}

Screenshot of program #1:

help_outline

Image Transcriptionclose

//Import required package import java.util. Random; import java.util.Scanner //Create a class public class ECommerceApp 1/Define a function public static String productsBuilder () 1/Return product catalog return "item ,book ,cassette "; //Define the function public static boolean getOrder(String name) { /Return the value returned from productsBuilder () return productsBuilder ().contains (name); }

fullscreen
Step 2

Screenshot of program #2:

help_outline

Image Transcriptionclose

//Define a function public static double getPrice() //Create object for Random class Random rand new Random) Return the random price calculated using random value*/ return rand.nextInt( (100 1) + 1) + 1; } //Define a function public static double getTax(double price) /Return 10 % tax of price return (price 10.0)/100.0; } //Define a function public static double getTotal(double price, double tax) //Return the total sale return price+tax; }

fullscreen
Step 3

Screenshot of program #3...

help_outline

Image Transcriptionclose

/Define a function public static void printTotal(double total) //Print the formatted output System.out.println (String.format("Your sale Total is $%.2f", total) ); } /Define the main() method public static void main(String [] args) { //print banner System.out.println("* \r\n" **** ** ***** . '====== Welcome to my eCommerce app! \r\n" + *****"); //Assign the value returned from productsBuilder () String productsCatalog = productsBuilder (); 1/Prompt the user to enter the product for order System.out.print (" Enter the product name for order: "); //Assign the order get f rom the user String ordername = new Scanner (System. in).next);

fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Hi, I have to code a java program that accepts the ingredients for a recipe in cups and converts to ...

A: Create a class and a class method which will calculate the number of ounce from the number of cups (...

question_answer

Q: I need help with this C++ problem.    Assume that a binary search function is searching for a value ...

A: Binary search: - It is a technique used to search an element in a sorted array.It is also known as h...

question_answer

Q: Translate the following pseudocode for finding the minimum value from a set of inputs.Set a Boolean ...

A: For solving this question first, we must know what pseudocode code is and what exactly question is a...

question_answer

Q: Python 3.7.4: (Introductory Level) Write a program that requests a word (in lowercase letters) as in...

A: This problem must be answered in Python 3 of the version 3.7.4. According the question its clearly a...

question_answer

Q: what is the difference between authentication and authorization? Can a system permit autorization wi...

A: Authentication: ⦁ Authentication means the system is going to grant access to any individual by veri...

question_answer

Q: Hi, I am required to: Create an array of 100 integers using a random generator. ( 1 for loop) Provi...

A: The given java program will follow the following rubrics:Importing essential header files.Creating a...

question_answer

Q: Within the NTDS folder, which file stores the main Active Directory database? Group of answer choice...

A: Within the NTDS folder, the “Ntds.dit”file stores the main Active Directory database .Hence, option ...

question_answer

Q: Write a C++ console application that allows your user to enter the total rainfall for each of 12 mon...

A: To write a C++ program that asks the user to enter total rainfall for 12 months into an array of dou...

question_answer

Q: Translate the following pseudocode for finding the minimum value from a set of inputs into a Java pr...

A: Java program to find the minimum valueimport java.util.Scanner; public class Program{     Public sta...