Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROJECT Sequential Control with Java - Trade Discounts / Net Prices Objective To construct a program that demonstrates sequential program control. PROJECT DESCRIPTION Sequential program

PROJECT Sequential Control with Java - Trade Discounts / Net Prices

Objective To construct a program that demonstrates sequential program control.

PROJECT DESCRIPTION

Sequential program control occurs when code statements are executed in sequence, one at a time, and without any decisions or loops.

Type, compile and run a computer program that uses sequential program control.

Your program is to receive trade discount data, according to the information given below, and then determine the net price amount of a merchandise purchase.

After you compile and run your program and observe the output, you will then modify the program with some extra refinements.

Some skeletal program code is shown in Figure 1 , which follows.

Information About This Project

A trade discount is a reduction from the manufacturers list price given to businesses that are in the trade. Trade discounts assist in the performance of marketing functions and are computed as follows:

Trade Discount

Trade Discount = List Price Rate

Net Price Amount

Net Price Amount = List Price Trade Discount

Example

Calculate the net price amount of merchandise listing for $ 2,300 less a trade discount of 37 % .

Solution

Trade Discount

Trade Discount = $ 2,300 37 %

Trade Discount = $ 851

Net Price Amount

Net Price Amount = $ 2,300 $ 851

Net Price Amount = $ 1,449

The Input, Process and Output ( IPOS ) requirements of this project are:

Input the user name, the list price of the item and the trade discount rate

Process the trade discount amount and the net price amount

Output the user name, the item description, the list price, the rate, the trade discount and the net price amount

Requirements all dollar amounts displayed in a currency format

PROJECT Sequential Control with Java - Trade Discounts / Net Prices

Steps to Complete This Project

STEP 1 Open an Integrated Development Environment ( IDE )

Open Eclipse, Net Beans, MS Visual Studio or similar programming text editor / compiler.

STEP 2 Write the Program Code

Write the program code that will satisfy the requirements of this project. That is, a program that will request the users name, the item that is to be discounted, the items list price and the discount rate.

When writing your code statements, use only sequential program control and avoid the use of any decision statements and any looping structures.

Into your Code window, copy the program code shown in Figure 1 . Substitute your own name in place of Sammy Student, as the program writer.

Figure 1 Program Code for the Trade Discount Application

import java.text.NumberFormat;

import java.text.SimpleDateFormat;

import java.util.Date;

public class TradeDiscount

{

public static void main(String[] args) {

// declare an object that will display two decimal digits

NumberFormat nf = NumberFormat.getCurrencyInstance();

// declare an object that will display the current date

Date myDate = new Date();

String myDateFormat = "MM/dd/yyyy";

SimpleDateFormat dtToday = new SimpleDateFormat(myDateFormat);

System.out.println("Today's Date is: " + dtToday.format(myDate));

// display the name of the programmer

System.out.println(" Programmer: " + " Sammy Student ");

// display a test value to show that two decimals are obtained

System.out.println(" test amount: " + nf.format(2.575));

}

}

The above starter code will display the current date and the name of the programmer. It also writes a sample test value to show that the two decimal format will display currency values, when it is used later in the program.

PROJECT Sequential Control with Java - Trade Discounts / Net Prices

STEP 3 Build, Compile and Run the Program

Compile and run your program code statements. Correct any syntax or compile errors.

STEP 4 Test the Program

Once you have successfully compiled your program, use the following data, when prompted, into the output Console window of your application.

Name of Program User : ( enter your own name )

Item Description : General Merchandise

The List Price : $ 2,980.00

Discount Rate : 9.20 %

STEP 5 Verify Your Output

When you enter the above information, the Console window should show your program output. Verify that the output is numerically accurate and that the required output information is displayed.

STEP 6 Modify Your Program

Return to your Code window and supplement the program with additional code statements, which you will basically place before the close of your main() method.

The purpose of these extra statements is to inform the program user that the trade discount will only be valid for one week from the current date.

To obtain next weeks date you can proceed as follows.

First, incorporate this import statement into your program.

import java.util.Calendar;

Next, instantiate a Calendar object into the program.

// a calendar object that defaults to "now"

Calendar cal = Calendar.getInstance();

Subsequently, set the calendar to next weeks date.

// add seven days to the current date

cal.add(Calendar.DATE, 7);

Now declare a Date object.

// obtain next weeks date

Date nextWeek = cal.getTime();

PROJECT Sequential Control with Java - Trade Discounts / Net Prices

Finally, similar to the println() statement that was used earlier to display the current date ( shown below ) , display next weeks date to the user.

System.out.println("Today's Date is: " + );

As stated earlier, inform the user that the trade discount is valid for only seven days.

Test your modified program.

STEP 7 Modify Again Your Program

Return to your Code window and supplement the program with even more additional code statements. Place the new statements, in appropriate places, before the close of your main() method.

The new statements will accomplish these tasks.

Compute and display the sales tax, which is based on the net price amount. Use a tax rate of 6.075 % .

Compute and display the shipping fee, which is a standard amount, added to the total purchase, of $ 75 , regardless of the amount of the merchandise.

Compute and display the commission, which is based on the net price of the merchandise purchased. Use a commission rate of 20 % .

Read and write the salespersons name. Store and retrieve the salespersons name using a String variable.

STEP 8 Test the Program

Once you have successfully compiled your program, use the following data, when prompted, into the output Console window of your application.

Name of Program User : ( enter your own name )

Item Description : General Merchandise

The List Price : $ 2,980.00

Discount Rate : 9.20 %

Salesperson Name : ( enter your own name )

Your program should then output each of the following quantities or values:

Output the user name, the item description, the list price, the rate, the trade discount amount, the net price amount, the sales tax, the total amount of the purchase, which includes the tax and the shipping fee, the commission amount and the salespersons name

PROJECT Sequential Control with Java - Trade Discounts / Net Prices

STEP 9 Submit Your Project

Once you have determined that your modified program is satisfying this projects requirements, complete the submission process as follows:

Open MS Word and type a heading for a new document that includes your full name, course number, lab number and date.

Within the document paste a snapshot of your program code. Label your snapshot with a reasonable description.

After the snapshot, paste the output that appears in your Console screen.

Note - you can use the Windows Snipping Tool, which is part of the Windows Accessories Group, to easily capture your Console window.

Your score for this project will generally be based upon the following factors: documentation, output correctness, content, organization, style and creativity. Submit your Word document to the appropriate course Submittal Box.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

New Trends In Databases And Information Systems Adbis 2019 Short Papers Workshops Bbigap Qauca Sembdm Simpda M2p Madeisd And Doctoral Consortium Bled Slovenia September 8 11 2019 Proceedings

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Robert Wrembel ,Mirjana Ivanovic ,Johann Gamper ,Mikolaj Morzy ,Theodoros Tzouramanis ,Jerome Darmont

1st Edition

3030302776, 978-3030302771

More Books

Students also viewed these Databases questions

Question

2. What are the components of IT infrastructure?

Answered: 1 week ago